| 48 | self.loader = MigrationLoader(apps_config, _NoopRecorder(), load=False) |
| 49 | |
| 50 | async def changes(self) -> list[MigrationWriter]: |
| 51 | await self.loader.build_graph() |
| 52 | old_state = await self._project_state() |
| 53 | new_state = self._current_state() |
| 54 | writers: list[MigrationWriter] = [] |
| 55 | for app_label, config in self.apps_config.items(): |
| 56 | migrations_module = config.get("migrations") |
| 57 | if not migrations_module: |
| 58 | continue |
| 59 | operations = OperationGenerator(old_state, new_state).generate(app_labels=[app_label]) |
| 60 | if not operations: |
| 61 | continue |
| 62 | dependencies = self._dependencies_for_app(app_label, new_state) |
| 63 | name, initial = self._migration_name(app_label, old_state, new_state) |
| 64 | writers.append( |
| 65 | MigrationWriter( |
| 66 | name, |
| 67 | app_label, |
| 68 | operations, |
| 69 | dependencies=dependencies, |
| 70 | initial=initial, |
| 71 | migrations_module=migrations_module, |
| 72 | ) |
| 73 | ) |
| 74 | return writers |
| 75 | |
| 76 | async def write(self) -> list[str]: |
| 77 | writers = await self.changes() |