-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrate.py
60 lines (42 loc) · 1.15 KB
/
migrate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from app.models import User, Role, Category
from core.database import model
from core.setting import setting
def create_roles() -> Role:
Role(name="customer").save() # 1
Role(name="employee").save() # 2
Role(name="admin").save() # 3
def create_users():
User.create(
username="cus_user",
password="1234567890",
role_id=1
) # customer
User.create(
username="emp_user",
password="1234567890",
role_id=2
)# employee
User.create(
username="admin",
password="1234567890",
role_id=3
) # admin
def create_category():
Category.create(name="doctor")
Category.create(name="lawyer")
Category.create(name="advisory")
def init_reset_database():
model.drop()
model.migrate()
# try:
# create defautl category
create_category()
# create default roles
create_roles()
# create dome user
create_users()
# except Exception as err:
# print(err.args)
if __name__ == "__main__":
# drop and create all tables
init_reset_database()