Skip to content

Commit

Permalink
fix: migrations to make it postgresql compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
qasimgulzar committed Dec 12, 2024
1 parent aa2b24e commit 962a413
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 121 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Generated by Django 3.2.15 on 2022-12-20 15:05

from django.db import connection, migrations


class Migration(migrations.Migration):
atomic = False

Expand All @@ -11,6 +8,7 @@ class Migration(migrations.Migration):
]

db_engine = connection.settings_dict['ENGINE']

if 'sqlite3' in db_engine:
operations = [
migrations.AlterIndexTogether(
Expand All @@ -19,23 +17,44 @@ class Migration(migrations.Migration):
),
]
else:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='blackboardlearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX blackboard_bldta_85936b55_idx
ON blackboard_blackboardlearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
ALGORITHM=INPLACE LOCK=NONE
""", reverse_sql="""
DROP INDEX blackboard_bldta_85936b55_idx
ON blackboard_blackboardlearnerdatatransmissionaudit
"""),
]
),
]
if 'postgresql' in db_engine:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='blackboardlearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX CONCURRENTLY blackboard_bldta_85936b55_idx
ON blackboard_blackboardlearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
""", reverse_sql="""
DROP INDEX CONCURRENTLY blackboard_bldta_85936b55_idx
"""),
]
),
]
else:
# For MySQL or other non-sqlite and non-postgresql backends
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='blackboardlearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX blackboard_bldta_85936b55_idx
ON blackboard_blackboardlearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
ALGORITHM=INPLACE LOCK=NONE
""", reverse_sql="""
DROP INDEX blackboard_bldta_85936b55_idx
ON blackboard_blackboardlearnerdatatransmissionaudit
"""),
]
),
]
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Generated by Django 3.2.15 on 2023-01-03 14:33

from django.db import connection, migrations


class Migration(migrations.Migration):

dependencies = [
('canvas', '0027_move_and_recrete_completed_timestamp'),
]

db_engine = connection.settings_dict['ENGINE']

if 'sqlite3' in db_engine:
operations = [
migrations.AlterIndexTogether(
Expand All @@ -18,23 +16,44 @@ class Migration(migrations.Migration):
),
]
else:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='canvaslearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX canvas_cldta_85936b55_idx
ON canvas_canvaslearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
ALGORITHM=INPLACE LOCK=NONE
""", reverse_sql="""
DROP INDEX canvas_cldta_85936b55_idx
ON canvas_canvaslearnerdatatransmissionaudit
"""),
]
),
]
if 'postgresql' in db_engine:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='canvaslearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX canvas_cldta_85936b55_idx
ON canvas_canvaslearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
""", reverse_sql="""
DROP INDEX CONCURRENTLY canvas_cldta_85936b55_idx
"""),
]
),
]
else:
# For MySQL or other non-sqlite and non-postgresql backends
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='canvaslearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX canvas_cldta_85936b55_idx
ON canvas_canvaslearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
ALGORITHM=INPLACE LOCK=NONE
""", reverse_sql="""
DROP INDEX canvas_cldta_85936b55_idx
ON canvas_canvaslearnerdatatransmissionaudit
"""),
]
),
]
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Generated by Django 3.2.15 on 2023-01-03 14:41

from django.db import connection, migrations


class Migration(migrations.Migration):

dependencies = [
('cornerstone', '0024_auto_20221031_1855'),
]

db_engine = connection.settings_dict['ENGINE']

if 'sqlite3' in db_engine:
operations = [
migrations.AlterIndexTogether(
Expand All @@ -18,23 +16,44 @@ class Migration(migrations.Migration):
),
]
else:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='cornerstonelearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX cornerstone_cldta_85936b55_idx
ON cornerstone_cornerstonelearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
ALGORITHM=INPLACE LOCK=NONE
""", reverse_sql="""
DROP INDEX cornerstone_cldta_85936b55_idx
ON cornerstone_cornerstonelearnerdatatransmissionaudit
"""),
]
),
]
if 'postgresql' in db_engine:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='cornerstonelearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX cornerstone_cldta_85936b55_idx
ON cornerstone_cornerstonelearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
""", reverse_sql="""
DROP INDEX cornerstone_cldta_85936b55_idx
"""),
]
),
]
else:
# For MySQL or other non-sqlite and non-postgresql backends
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='cornerstonelearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX cornerstone_cldta_85936b55_idx
ON cornerstone_cornerstonelearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
ALGORITHM=INPLACE LOCK=NONE
""", reverse_sql="""
DROP INDEX cornerstone_cldta_85936b55_idx
ON cornerstone_cornerstonelearnerdatatransmissionaudit
"""),
],
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,26 @@ class Migration(migrations.Migration):
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
]
else:
elif 'postgresql' in db_engine:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='degreedlearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX degreed_dldta_85936b55_idx
ON degreed_degreedlearnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
""", reverse_sql="""
DROP INDEX degreed_dldta_85936b55_idx
"""),
]
),
]
elif 'mysql' in db_engine:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
Expand All @@ -38,3 +57,10 @@ class Migration(migrations.Migration):
]
),
]
else:
operations = [
migrations.AlterIndexTogether(
name='degreedlearnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,26 @@ class Migration(migrations.Migration):
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
]
else:
elif 'postgresql' in db_engine:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterIndexTogether(
name='degreed2learnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
],
database_operations=[
migrations.RunSQL(sql="""
CREATE INDEX degreed2_dldta_85936b55_idx
ON degreed2_degreed2learnerdatatransmissionaudit (enterprise_customer_uuid, plugin_configuration_id)
""", reverse_sql="""
DROP INDEX degreed2_dldta_85936b55_idx
"""),
]
),
]
elif 'mysql' in db_engine:
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
Expand All @@ -38,3 +57,10 @@ class Migration(migrations.Migration):
]
),
]
else:
operations = [
migrations.AlterIndexTogether(
name='degreed2learnerdatatransmissionaudit',
index_together={('enterprise_customer_uuid', 'plugin_configuration_id')},
),
]
Loading

0 comments on commit 962a413

Please sign in to comment.