mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-09-10 14:02:35 +03:00
Merge pull request #4 from mabdullahadeel/feature/mysql-8-support
mysql 8 support - updated django migration init scripts.
This commit is contained in:
commit
21a9438751
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
|
@ -44,9 +44,9 @@ jobs:
|
|||
matrix:
|
||||
script:
|
||||
- name: Basic
|
||||
args: ""
|
||||
args: "database_engine=postgresql database_version=postgresql@14.1"
|
||||
- name: Extended
|
||||
args: "use_celery=y use_drf=y js_task_runner=Gulp"
|
||||
args: "use_celery=y use_drf=y js_task_runner=Gulp database_engine=postgresql database_version=postgresql@14.1"
|
||||
|
||||
name: "${{ matrix.script.name }} Docker"
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -71,9 +71,12 @@ jobs:
|
|||
matrix:
|
||||
script:
|
||||
- name: With Celery
|
||||
args: "use_celery=y use_compressor=y"
|
||||
args: "use_celery=y use_compressor=y database_engine=postgresql database_version=postgresql@14.1"
|
||||
# postgres://user:password@host:port/database
|
||||
database_url: "postgres://postgres:postgres@localhost:5432/postgres"
|
||||
- name: With Gulp
|
||||
args: "js_task_runner=Gulp custom_bootstrap_compilation=y"
|
||||
args: "js_task_runner=Gulp custom_bootstrap_compilation=y database_engine=postgresql database_version=postgresql@14.1"
|
||||
database_url: "postgres://postgres:postgres@localhost:5432/postgres"
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
name: "${{ matrix.script.name }} Bare metal"
|
||||
|
@ -91,8 +94,7 @@ jobs:
|
|||
|
||||
env:
|
||||
CELERY_BROKER_URL: "redis://localhost:6379/0"
|
||||
# postgres://user:password@host:port/database
|
||||
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres"
|
||||
DATABASE_URL: ${{ matrix.script.database_url }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
"postgresql@12.9",
|
||||
"postgresql@11.14",
|
||||
"postgresql@10.19",
|
||||
"mysql@8.0.28",
|
||||
"mysql@8.0",
|
||||
"mysql@5.7"
|
||||
],
|
||||
"__processed_database_engine": "{{ cookiecutter.database_version.lower()|split('@')[0] }}",
|
||||
|
|
|
@ -52,6 +52,8 @@ SUPPORTED_COMBINATIONS = [
|
|||
{"database_engine": "postgresql", "database_version": "postgresql@12.9"},
|
||||
{"database_engine": "postgresql", "database_version": "postgresql@11.14"},
|
||||
{"database_engine": "postgresql", "database_version": "postgresql@10.1 9"},
|
||||
{"database_engine": "mysql", "database_version": "mysql@8.0.28"},
|
||||
{"database_engine": "mysql", "database_version": "mysql@8.0"},
|
||||
{"database_engine": "mysql", "database_version": "mysql@5.7"},
|
||||
{"cloud_provider": "AWS", "use_whitenoise": "y"},
|
||||
{"cloud_provider": "AWS", "use_whitenoise": "n"},
|
||||
|
@ -118,6 +120,8 @@ UNSUPPORTED_COMBINATIONS = [
|
|||
{"cloud_provider": "None", "use_whitenoise": "n"},
|
||||
{"cloud_provider": "GCP", "mail_service": "Amazon SES"},
|
||||
{"cloud_provider": "None", "mail_service": "Amazon SES"},
|
||||
{"database_engine": "postgresql", "database_version": "mysql@8.0.28"},
|
||||
{"database_engine": "postgresql", "database_version": "mysql@8.0"},
|
||||
{"database_engine": "postgresql", "database_version": "mysql@5.7"},
|
||||
{"database_engine": "mysql", "database_version": "postgresql@14.1"},
|
||||
{"database_engine": "mysql", "database_version": "postgresql@13.5"},
|
||||
|
|
|
@ -25,6 +25,7 @@ def _update_or_create_site_with_sequence(site_model, connection, domain, name):
|
|||
# greater than the maximum value.
|
||||
max_id = site_model.objects.order_by('-id').first().id
|
||||
with connection.cursor() as cursor:
|
||||
{%- if cookiecutter.database_engine == 'postgresql' %}
|
||||
cursor.execute("SELECT last_value from django_site_id_seq")
|
||||
(current_id,) = cursor.fetchone()
|
||||
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",
|
||||
[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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user