forked from jafarbekyusupov/bankingSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_db.py
More file actions
25 lines (20 loc) · 638 Bytes
/
init_db.py
File metadata and controls
25 lines (20 loc) · 638 Bytes
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
from src.app import create_app, init_database
from src.models import db
def main():
print(" Init-ng Banking System DB...")
app = create_app()
with app.app_context():
try:
from src.models import User
User.query.count()
print("DB struct looks good") # no need to reset it
except Exception as e:
print(f"!!!!!!!!!!! DB STRUCT ISSUE DETECTED: {e}")
print("+++ RESETTING DB... +++")
db.drop_all() # to recreate
print("dropped old tables")
init_database()
print("\n ========= DB INIT IS DONE ========= ")
print("NOW data migration is possible -- python migrate_data.py")
if __name__ == '__main__':
main()