3 | | The `sqlmigrate` command does not follow `replaces` in squashed migration, with original (squashed) migration files deleted. This ticket is roughly the same than #32205, #33583 and #31318. In #31318, the issue is marked as solved with commit [https://github.com/django/django/commit/d88365708c554efe3c786c3be6da1d9de916360f d883657]. Since then, `MigrationLoader` accepts the argument `replace_migrations`. However, [https://github.com/django/django/blob/d88365708c554efe3c786c3be6da1d9de916360f/django/core/management/commands/sqlmigrate.py#L37 the loader instance here] has this option to `False`. I don't see a command option to set it to `True`. |
| 3 | The `sqlmigrate` command does not follow `replaces` in squashed migration, with original (squashed) migration files deleted. This ticket is roughly the same than #33583. In #31318, the issue is marked as solved with commit [https://github.com/django/django/commit/d88365708c554efe3c786c3be6da1d9de916360f d883657]. Since then, `MigrationLoader` accepts the argument `replace_migrations`. However, [https://github.com/django/django/blob/d88365708c554efe3c786c3be6da1d9de916360f/django/core/management/commands/sqlmigrate.py#L37 the loader instance here] has this option to `False`. I don't see a command option to set it to `True`. |
| 4 | |
| 5 | Sample error (not mine, but actually the exact same, taken from #33583): |
| 6 | |
| 7 | {{{ |
| 8 | python3 manage.py sqlmigrate beta 0003 |
| 9 | Traceback (most recent call last): |
| 10 | File "/Users/amin/sandbox/mysite/manage.py", line 22, in <module> |
| 11 | main() |
| 12 | File "/Users/amin/sandbox/mysite/manage.py", line 18, in main |
| 13 | execute_from_command_line(sys.argv) |
| 14 | File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line |
| 15 | utility.execute() |
| 16 | File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute |
| 17 | self.fetch_command(subcommand).run_from_argv(self.argv) |
| 18 | File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv |
| 19 | self.execute(*args, **cmd_options) |
| 20 | File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/sqlmigrate.py", line 38, in execute |
| 21 | return super().execute(*args, **options) |
| 22 | File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 460, in execute |
| 23 | output = self.handle(*args, **options) |
| 24 | File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/sqlmigrate.py", line 46, in handle |
| 25 | loader = MigrationLoader(connection, replace_migrations=False) |
| 26 | File "/usr/local/lib/python3.9/site-packages/django/db/migrations/loader.py", line 58, in __init__ |
| 27 | self.build_graph() |
| 28 | File "/usr/local/lib/python3.9/site-packages/django/db/migrations/loader.py", line 276, in build_graph |
| 29 | self.graph.validate_consistency() |
| 30 | File "/usr/local/lib/python3.9/site-packages/django/db/migrations/graph.py", line 198, in validate_consistency |
| 31 | [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] |
| 32 | File "/usr/local/lib/python3.9/site-packages/django/db/migrations/graph.py", line 198, in <listcomp> |
| 33 | [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] |
| 34 | File "/usr/local/lib/python3.9/site-packages/django/db/migrations/graph.py", line 60, in raise_error |
| 35 | raise NodeNotFoundError(self.error_message, self.key, origin=self.origin) |
| 36 | django.db.migrations.exceptions.NodeNotFoundError: Migration beta.0001_initial dependencies reference nonexistent parent node ('first', '0001_initial') |
| 37 | }}} |