feat: replace php migration with django migration
- keep latest legacy version in initial migration file - move propel schema to api legacy app - remove legacy upgrade tool
This commit is contained in:
parent
ee98387264
commit
0e4bc4cacd
85 changed files with 1005 additions and 1000 deletions
29
api/libretime_api/legacy/migrations/0001_initial.py
Normal file
29
api/libretime_api/legacy/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from pathlib import Path
|
||||
|
||||
from django.db import connection, migrations
|
||||
|
||||
from . import LEGACY_SCHEMA_VERSION
|
||||
from ._migrations import get_schema_version, set_schema_version
|
||||
|
||||
here = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
def create_schema(_apps, _schema_editor):
|
||||
schema_version = get_schema_version()
|
||||
|
||||
# A schema already exists, don't overwrite !
|
||||
if schema_version is not None:
|
||||
return
|
||||
|
||||
with connection.cursor() as cursor:
|
||||
for migration_filename in ("schema.sql", "data.sql"):
|
||||
raw = (here / "sql" / migration_filename).read_text(encoding="utf-8")
|
||||
cursor.execute(raw)
|
||||
|
||||
set_schema_version(cursor, LEGACY_SCHEMA_VERSION)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
dependencies = []
|
||||
operations = [migrations.RunPython(create_schema)]
|
Loading…
Add table
Add a link
Reference in a new issue