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

Use db_default for auto-UUID fields in Django 5 #10958

Closed
jacobtylerwalls opened this issue May 22, 2024 · 1 comment · Fixed by #11792
Closed

Use db_default for auto-UUID fields in Django 5 #10958

jacobtylerwalls opened this issue May 22, 2024 · 1 comment · Fixed by #11792
Assignees

Comments

@jacobtylerwalls
Copy link
Member

When Django 5 is the minimum required version, we can just use db_default for database-generated UUIDs and drop our custom implementation, which currently throws errors if you try to manage.py sqlmigrate:

$ manage.py sqlmigrate models 0001
Traceback (most recent call last):
  File "/Users/jwalls/prj/arches/manage.py", line 27, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/jwalls/django/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/Users/jwalls/django/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/jwalls/django/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/jwalls/django/django/core/management/commands/sqlmigrate.py", line 38, in execute
    return super().execute(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalls/django/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalls/django/django/core/management/commands/sqlmigrate.py", line 80, in handle
    sql_statements = loader.collect_sql(plan)
                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalls/django/django/db/migrations/loader.py", line 381, in collect_sql
    state = migration.apply(state, schema_editor, collect_sql=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalls/django/django/db/migrations/migration.py", line 108, in apply
    schema_editor.collected_sql.append("-- %s" % operation.describe())
                                                 ^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalls/prj/arches/arches/db/migration_operations/extras.py", line 126, in describe
    return "Sets default value for uuid column(s) %s in %s" % self.columns, self.table
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
TypeError: not enough arguments for format string
@chiatt chiatt added this to pipeline May 22, 2024
@jacobtylerwalls
Copy link
Member Author

Consider removing CreateAutoPopulateUUIDField at the same time.

@jacobtylerwalls jacobtylerwalls self-assigned this Aug 21, 2024
@jacobtylerwalls jacobtylerwalls moved this to 🏗 In Progress in pipeline Nov 6, 2024
@jacobtylerwalls jacobtylerwalls moved this from 🏗 In Progress to 👀 In Review in pipeline Feb 18, 2025
@github-project-automation github-project-automation bot moved this from 👀 In Review to ✅ Done in pipeline Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant