mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-19 03:14:52 +03:00
🔧 updated migrations scripts to support mysql
This commit is contained in:
parent
5563073bf3
commit
b1e86eec17
|
@ -25,6 +25,7 @@ def _update_or_create_site_with_sequence(site_model, connection, domain, name):
|
||||||
# greater than the maximum value.
|
# greater than the maximum value.
|
||||||
max_id = site_model.objects.order_by('-id').first().id
|
max_id = site_model.objects.order_by('-id').first().id
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
|
{% if cookiecutter.database_engine == 'postgresql' -%}
|
||||||
cursor.execute("SELECT last_value from django_site_id_seq")
|
cursor.execute("SELECT last_value from django_site_id_seq")
|
||||||
(current_id,) = cursor.fetchone()
|
(current_id,) = cursor.fetchone()
|
||||||
if current_id <= max_id:
|
if current_id <= max_id:
|
||||||
|
@ -32,6 +33,15 @@ def _update_or_create_site_with_sequence(site_model, connection, domain, name):
|
||||||
"alter sequence django_site_id_seq restart with %s",
|
"alter sequence django_site_id_seq restart with %s",
|
||||||
[max_id + 1],
|
[max_id + 1],
|
||||||
)
|
)
|
||||||
|
{% elif cookiecutter.database_engine == 'mysql' -%}
|
||||||
|
cursor.execute("SELECT MAX(id) FROM django_site")
|
||||||
|
(current_id,) = cursor.fetchone()
|
||||||
|
if current_id <= max_id:
|
||||||
|
cursor.execute(
|
||||||
|
"ALTER TABLE django_site AUTO_INCREMENT=%s",
|
||||||
|
[max_id + 1],
|
||||||
|
)
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
|
|
||||||
def update_site_forward(apps, schema_editor):
|
def update_site_forward(apps, schema_editor):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user