diff options
| author | Jan T <jan@jantuomi.fi> | 2024-02-28 17:32:01 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-12-21 19:43:13 +0200 |
| commit | b6bc5c5794b4df182175da34e6b08298084c0324 (patch) | |
| tree | 501362805ac744eb71e0e9d7b70addb9f0c9ae99 /apply_migrations.py | |
Initial commit
Diffstat (limited to 'apply_migrations.py')
| -rw-r--r-- | apply_migrations.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/apply_migrations.py b/apply_migrations.py new file mode 100644 index 0000000..4ade81e --- /dev/null +++ b/apply_migrations.py @@ -0,0 +1,25 @@ +from dotenv import load_dotenv +load_dotenv() + +import os +import db + +migrations_dir = 'migrations' # Relative directory path + +# Get all migration files +migration_files = sorted(os.listdir(migrations_dir)) + +# Apply migrations in alphabetical order +for migration_file in migration_files: + migration_path = os.path.join(migrations_dir, migration_file) + print(f"* Applying migration: {migration_path}") + + with open(migration_path, 'r') as f: + migration_sql = f.read() + + print(migration_sql) + + db.apply_migration(migration_sql) + print(f"* Migration applied: {migration_path}") + +print(f"* {len(migration_files)} migrations applied.") |
