Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: migrations to make it postgresql compatible. #2281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading