microsoft / mssql-django

The Microsoft Django backend for SQL Server provides a connectivity layer for Django on SQL Server or Azure SQL DB.
Other
350 stars 115 forks source link

Migrate Failed with Django 5.1 #407

Open wilson-jw opened 3 months ago

wilson-jw commented 3 months ago

Hi team, I would like to get your help on migration error.

Software versions

Problem description and steps to reproduce Failed to run py manage.py migrate command with below error message.

Error message/stack trace

Running migrations:
  Applying history.0001_initial...Traceback (most recent call last):
  File "E:\wilson\ATS_VM_Solution\vmportal\manage.py", line 22, in <module>
    main()
  File "E:\DjangoProj\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "E:\DjangoProj\.venv\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "E:\DjangoProj\.venv\Lib\site-packages\django\core\management\__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "E:\DjangoProj\.venv\Lib\site-packages\django\core\management\base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "E:\DjangoProj\.venv\Lib\site-packages\django\core\management\base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\DjangoProj\.venv\Lib\site-packages\django\core\management\base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\DjangoProj\.venv\Lib\site-packages\django\core\management\commands\migrate.py", line 357, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "E:\DjangoProj\.venv\Lib\site-packages\django\db\migrations\executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\DjangoProj\.venv\Lib\site-packages\django\db\migrations\executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "E:\DjangoProj\.venv\Lib\site-packages\django\db\migrations\executor.py", line 255, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\DjangoProj\.venv\Lib\site-packages\django\db\migrations\migration.py", line 132, in apply
    operation.database_forwards(
  File "E:\DjangoProj\.venv\Lib\site-packages\django\db\migrations\operations\models.py", line 97, in database_forwards
    schema_editor.create_model(model)
  File "E:\DjangoProj\.venv\Lib\site-packages\mssql\schema.py", line 1326, in create_model
    self.deferred_sql.extend(self._model_indexes_sql(model))
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\DjangoProj\.venv\Lib\site-packages\mssql\schema.py", line 302, in _model_indexes_sql
    for field_names in model._meta.index_together:
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Options' object has no attribute 'index_together'. Did you mean: 'unique_together'?

Any other details that can be helpful It seems that the new version of Django has changed the field parameter settings, resulting in the field not being found. Please help to check.

wilson-jw commented 3 months ago

migrate command works well with Django 5.0.8 version. Only get error when upgrade to 5.1 version.

MichaelSun90 commented 3 months ago

Hi @wilson-jw, the team still working on 5.1 support. Will let you know when that is ready.

Eric-Simon-Lemon commented 2 months ago

@MichaelSun90 Hello sir, any news about the 5.1 support ? It's already been 2 months since the end of mainstream support for 5.0.x Thank you for you answer

sohamM97 commented 3 weeks ago

Hello @MichaelSun90 Any estimated release date for mssql-django with Django 5.1 support? We are migrating our application from Django 3.2 to Django 5, and would like to use Django 5.1 instead of 5.0, as that's the latest version (we would ideally want to upgrade to Django 5.2 as soon as that's released as well).

vsds-cbs-nl commented 2 weeks ago

418

OndrejSerek commented 1 week ago

Any updates to this please?

maclinbc commented 4 days ago

I've found that the changes made in the django51 branch fixed many of the issues I was having https://github.com/microsoft/mssql-django/tree/django51