2021-07-21 06:58:49 +00:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
|
2021-07-21 08:03:49 +00:00
|
|
|
DB_DIR = "./Props"
|
2021-07-21 06:58:49 +00:00
|
|
|
DATA_DIR = "Data"
|
|
|
|
DB_MIGRATE_CMD = "dotnet ef migrations add InitialCreate -o {0}"
|
|
|
|
DB_UPDATE_CMD = "dotnet ef database update"
|
|
|
|
|
|
|
|
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
|
|
|
os.chdir("..")
|
2021-07-21 08:03:49 +00:00
|
|
|
os.chdir(DB_DIR)
|
2021-07-21 06:58:49 +00:00
|
|
|
print("Working in: " + os.getcwd())
|
|
|
|
|
|
|
|
migrationsDir = os.path.join(DATA_DIR, "Migrations")
|
|
|
|
|
|
|
|
print("Deleting current migrations directory if it exists.")
|
|
|
|
shutil.rmtree(migrationsDir, ignore_errors=True)
|
|
|
|
|
|
|
|
print("Deleting old app.db if it exists.")
|
|
|
|
if os.path.exists("app.db"):
|
|
|
|
os.remove("app.db")
|
|
|
|
|
|
|
|
print("Creating migration.")
|
|
|
|
os.system(DB_MIGRATE_CMD.format(migrationsDir))
|
|
|
|
|
|
|
|
print("Updating database.")
|
|
|
|
os.system(DB_UPDATE_CMD)
|