amsdal_cli 0.4.16__py3-none-any.whl → 0.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
amsdal_cli/__about__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2023-present
2
2
  #
3
3
  # SPDX-License-Identifier: AMSDAL End User License Agreement
4
- __version__ = '0.4.16'
4
+ __version__ = '0.5.1'
@@ -49,7 +49,7 @@ class BuildMixin:
49
49
 
50
50
  shutil.copytree(
51
51
  models_source_path,
52
- settings.USER_MODELS_MODULE_PATH,
52
+ settings.USER_MODELS_MODULE_PATH, # type: ignore[arg-type]
53
53
  dirs_exist_ok=True,
54
54
  )
55
55
 
@@ -246,7 +246,6 @@ def _check_missing_generated_migrations(
246
246
  from amsdal.configs.constants import CORE_MIGRATIONS_PATH
247
247
  from amsdal.configs.main import settings
248
248
  from amsdal_models.migration.file_migration_generator import FileMigrationGenerator
249
- from amsdal_utils.models.enums import ModuleType
250
249
 
251
250
  from amsdal_cli.commands.migrations.constants import MIGRATIONS_DIR_NAME
252
251
  from amsdal_cli.utils.cli_config import ModelsFormat
@@ -261,7 +260,7 @@ def _check_missing_generated_migrations(
261
260
  if not amsdal_manager.is_authenticated:
262
261
  amsdal_manager.authenticate()
263
262
 
264
- amsdal_manager.post_setup()
263
+ amsdal_manager.post_setup() # type: ignore[call-arg]
265
264
  migrations_dir = app_source_path / MIGRATIONS_DIR_NAME
266
265
  cli_config.models_format = ModelsFormat.PY
267
266
  schema_repository = build_schema_repository(cli_config=cli_config)
@@ -270,8 +269,9 @@ def _check_missing_generated_migrations(
270
269
  app_migrations_path=migrations_dir,
271
270
  contrib_migrations_directory_name=settings.CONTRIB_MODELS_PACKAGE_NAME,
272
271
  )
272
+ generator.init_state()
273
273
 
274
- operations = generator.generate_operations(schema_repository.user_schemas, ModuleType.USER)
274
+ operations = generator.app_file_migration_generator.generate_operations(schema_repository.user_schemas)
275
275
 
276
276
  if operations:
277
277
  rprint(rich_error('Missing generated migrations. Use `amsdal migrations new` to fix. Exiting...'))
@@ -295,7 +295,6 @@ async def _async_check_missing_generated_migrations(
295
295
  from amsdal.configs.constants import CORE_MIGRATIONS_PATH
296
296
  from amsdal.configs.main import settings
297
297
  from amsdal_models.migration.file_migration_generator import AsyncFileMigrationGenerator
298
- from amsdal_utils.models.enums import ModuleType
299
298
 
300
299
  from amsdal_cli.commands.migrations.constants import MIGRATIONS_DIR_NAME
301
300
  from amsdal_cli.utils.cli_config import ModelsFormat
@@ -310,7 +309,7 @@ async def _async_check_missing_generated_migrations(
310
309
  if not amsdal_manager.is_authenticated:
311
310
  amsdal_manager.authenticate()
312
311
 
313
- await amsdal_manager.post_setup()
312
+ await amsdal_manager.post_setup() # type: ignore[call-arg, misc]
314
313
 
315
314
  migrations_dir = app_source_path / MIGRATIONS_DIR_NAME
316
315
 
@@ -321,8 +320,9 @@ async def _async_check_missing_generated_migrations(
321
320
  app_migrations_path=migrations_dir,
322
321
  contrib_migrations_directory_name=settings.CONTRIB_MODELS_PACKAGE_NAME,
323
322
  )
323
+ await generator.init_state()
324
324
 
325
- operations = await generator.generate_operations(schema_repository.user_schemas, ModuleType.USER)
325
+ operations = generator.app_file_migration_generator.generate_operations(schema_repository.user_schemas)
326
326
 
327
327
  if operations:
328
328
  rprint(rich_error('Missing generated migrations. Use `amsdal migrations new` to fix. Exiting...'))
@@ -105,7 +105,7 @@ def generate_model(
105
105
 
106
106
  if unique_attrs:
107
107
  _unique = json_schema.setdefault('unique', [])
108
- _unique.extend(unique_attrs) # type: ignore[attr-defined]
108
+ _unique.extend(unique_attrs)
109
109
 
110
110
  for attr in parsed_attrs:
111
111
  property_info: dict[str, Any] = {
@@ -30,6 +30,7 @@ def _sync_apply(
30
30
  from amsdal_models.migration.file_migration_executor import FileMigrationExecutorManager
31
31
  from amsdal_models.migration.migrations import MigrationSchemas
32
32
  from amsdal_models.migration.migrations_loader import MigrationsLoader
33
+ from amsdal_models.migration.utils import build_migrations_module_name
33
34
 
34
35
  from amsdal_cli.commands.migrations.constants import MIGRATIONS_DIR_NAME
35
36
  from amsdal_cli.utils.text import rich_info
@@ -42,11 +43,15 @@ def _sync_apply(
42
43
  amsdal_manager.setup()
43
44
 
44
45
  amsdal_manager.authenticate()
45
- amsdal_manager.post_setup()
46
+ amsdal_manager.post_setup() # type: ignore[call-arg]
46
47
 
47
48
  app_migrations_loader = MigrationsLoader(
48
49
  migrations_dir=build_dir / MIGRATIONS_DIR_NAME,
49
50
  module_type=ModuleType.USER,
51
+ module_name=build_migrations_module_name(
52
+ None,
53
+ MIGRATIONS_DIR_NAME,
54
+ ),
50
55
  )
51
56
  schemas = MigrationSchemas()
52
57
 
@@ -101,9 +106,9 @@ async def _async_sync_apply(
101
106
  from amsdal_models.migration.data_classes import MigrationResult
102
107
  from amsdal_models.migration.executors.default_executor import DefaultAsyncMigrationExecutor
103
108
  from amsdal_models.migration.file_migration_executor import AsyncFileMigrationExecutorManager
104
- from amsdal_models.migration.file_migration_store import AsyncFileMigrationStore
105
109
  from amsdal_models.migration.migrations import MigrationSchemas
106
110
  from amsdal_models.migration.migrations_loader import MigrationsLoader
111
+ from amsdal_models.migration.utils import build_migrations_module_name
107
112
 
108
113
  from amsdal_cli.commands.migrations.constants import MIGRATIONS_DIR_NAME
109
114
  from amsdal_cli.utils.text import rich_info
@@ -116,14 +121,16 @@ async def _async_sync_apply(
116
121
 
117
122
  try:
118
123
  amsdal_manager.authenticate()
119
- store = AsyncFileMigrationStore(build_dir / MIGRATIONS_DIR_NAME)
120
124
 
121
- await store.init_migration_table()
122
- await amsdal_manager.post_setup()
125
+ await amsdal_manager.post_setup() # type: ignore[call-arg, misc]
123
126
 
124
127
  app_migrations_loader = MigrationsLoader(
125
128
  migrations_dir=build_dir / MIGRATIONS_DIR_NAME,
126
129
  module_type=ModuleType.USER,
130
+ module_name=build_migrations_module_name(
131
+ None,
132
+ MIGRATIONS_DIR_NAME,
133
+ ),
127
134
  )
128
135
  schemas = MigrationSchemas()
129
136
 
@@ -19,9 +19,11 @@ def _fetch_migrations(app_migrations_path: Path) -> list['MigrationFile']:
19
19
  if not amsdal_manager.is_setup:
20
20
  amsdal_manager.setup()
21
21
  amsdal_manager.authenticate()
22
- amsdal_manager.post_setup()
22
+ amsdal_manager.post_setup() # type: ignore[call-arg]
23
23
 
24
24
  store = FileMigrationStore(app_migrations_path)
25
+ store.init_migration_table()
26
+
25
27
  return store.fetch_migrations()
26
28
 
27
29
 
@@ -35,7 +37,7 @@ async def _async_fetch_migrations(app_migrations_path: Path) -> list['MigrationF
35
37
 
36
38
  try:
37
39
  amsdal_manager.authenticate()
38
- await amsdal_manager.post_setup()
40
+ await amsdal_manager.post_setup() # type: ignore[call-arg,misc]
39
41
 
40
42
  store = AsyncFileMigrationStore(app_migrations_path)
41
43
  await store.init_migration_table()
@@ -58,6 +60,7 @@ def list_migrations(
58
60
  from amsdal.configs.main import settings
59
61
  from amsdal_models.migration.data_classes import ModuleType
60
62
  from amsdal_models.migration.migrations_loader import MigrationsLoader
63
+ from amsdal_models.migration.utils import build_migrations_module_name
61
64
  from amsdal_models.migration.utils import contrib_to_module_root_path
62
65
  from amsdal_utils.config.manager import AmsdalConfigManager
63
66
 
@@ -94,6 +97,10 @@ def list_migrations(
94
97
  core_loader = MigrationsLoader(
95
98
  migrations_dir=CORE_MIGRATIONS_PATH,
96
99
  module_type=ModuleType.CORE,
100
+ module_name=build_migrations_module_name(
101
+ 'amsdal',
102
+ '__migrations__',
103
+ ),
97
104
  )
98
105
  contrib_loaders: list[tuple[str, MigrationsLoader]] = []
99
106
 
@@ -106,7 +113,10 @@ def list_migrations(
106
113
  MigrationsLoader(
107
114
  migrations_dir=contrib_root_path / settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
108
115
  module_type=ModuleType.CONTRIB,
109
- module_name=contrib,
116
+ module_name=build_migrations_module_name(
117
+ '.'.join(contrib.split('.')[:-2]),
118
+ settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
119
+ ),
110
120
  ),
111
121
  ),
112
122
  )
@@ -114,6 +124,10 @@ def list_migrations(
114
124
  app_migrations_loader = MigrationsLoader(
115
125
  migrations_dir=build_dir / MIGRATIONS_DIR_NAME,
116
126
  module_type=ModuleType.USER,
127
+ module_name=build_migrations_module_name(
128
+ None,
129
+ MIGRATIONS_DIR_NAME,
130
+ ),
117
131
  )
118
132
 
119
133
  rprint(rich_success('Core:'))
@@ -126,7 +140,11 @@ def list_migrations(
126
140
  rprint(rich_success('Contrib:'))
127
141
  for _contrib, _loader in contrib_loaders:
128
142
  _contrib_name = _contrib.rsplit('.', 2)[0]
129
- _applied_numbers = _contrib_applied_numbers[_contrib]
143
+ _contrib_module_name = build_migrations_module_name(
144
+ '.'.join(_contrib.split('.')[:-2]),
145
+ settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
146
+ )
147
+ _applied_numbers = _contrib_applied_numbers[_contrib_module_name]
130
148
 
131
149
  for _migration in _loader:
132
150
  _is_migrated = 'x' if _migration.number in _applied_numbers else ' '
@@ -36,7 +36,7 @@ def _sync_make_migrations(
36
36
  if not amsdal_manager._is_setup:
37
37
  amsdal_manager.setup()
38
38
  amsdal_manager.authenticate()
39
- amsdal_manager.post_setup()
39
+ amsdal_manager.post_setup() # type: ignore[call-arg]
40
40
 
41
41
  schema_repository = build_schema_repository(cli_config=cli_config)
42
42
  migrations_dir: Path = cli_config.app_directory / SOURCES_DIR / MIGRATIONS_DIR_NAME
@@ -44,7 +44,7 @@ def _sync_make_migrations(
44
44
  generator = FileMigrationGenerator(
45
45
  core_migrations_path=CORE_MIGRATIONS_PATH,
46
46
  app_migrations_path=migrations_dir,
47
- contrib_migrations_directory_name=settings.CONTRIB_MODELS_PACKAGE_NAME,
47
+ contrib_migrations_directory_name=settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
48
48
  )
49
49
 
50
50
  try:
@@ -89,7 +89,7 @@ async def _async_make_migrations(
89
89
  if not amsdal_manager.is_setup:
90
90
  await amsdal_manager.setup()
91
91
  amsdal_manager.authenticate()
92
- await amsdal_manager.post_setup()
92
+ await amsdal_manager.post_setup() # type: ignore[call-arg, misc]
93
93
 
94
94
  schema_repository = build_schema_repository(cli_config=cli_config)
95
95
  migrations_dir: Path = cli_config.app_directory / SOURCES_DIR / MIGRATIONS_DIR_NAME
@@ -11,6 +11,10 @@ async def init_amsdal(config_path: Path, temp_dir: Path) -> None:
11
11
  USER_MODELS_MODULE_PATH=temp_dir / 'models',
12
12
  )
13
13
 
14
+ if not settings.USER_MODELS_MODULE_PATH:
15
+ msg = 'USER_MODELS_MODULE_PATH must be set in settings.'
16
+ raise ValueError(msg)
17
+
14
18
  settings.USER_MODELS_MODULE_PATH.mkdir(parents=True, exist_ok=True)
15
19
  (settings.USER_MODELS_MODULE_PATH / '__init__.py').touch(exist_ok=True)
16
20
 
@@ -25,7 +29,7 @@ async def init_amsdal(config_path: Path, temp_dir: Path) -> None:
25
29
  amsdal_manager = AmsdalManager()
26
30
  amsdal_manager.setup()
27
31
  amsdal_manager.authenticate()
28
- amsdal_manager.post_setup()
32
+ amsdal_manager.post_setup() # type: ignore[call-arg]
29
33
 
30
34
 
31
35
  async def _async_init() -> None:
@@ -34,4 +38,4 @@ async def _async_init() -> None:
34
38
  amsdal_manager = AsyncAmsdalManager()
35
39
  await amsdal_manager.setup()
36
40
  amsdal_manager.authenticate()
37
- await amsdal_manager.post_setup()
41
+ await amsdal_manager.post_setup() # type: ignore[call-arg, misc]
@@ -50,7 +50,7 @@ async def migrate_models_to_lakehouse(
50
50
  build_dir=temp_dir,
51
51
  )
52
52
 
53
- sys.path.insert(0, str(settings.USER_MODELS_MODULE_PATH.absolute()))
53
+ sys.path.insert(0, str(settings.USER_MODELS_MODULE_PATH.absolute())) # type: ignore[union-attr]
54
54
 
55
55
  if config_manager.get_config().async_mode:
56
56
  await _async_migrate_models(config_path)
@@ -72,7 +72,7 @@ def _migrate_models(config_path: Path) -> None:
72
72
  from amsdal_models.classes.class_loader import ModelClassLoader
73
73
  from amsdal_models.migration import migrations
74
74
  from amsdal_models.migration.executors.default_executor import DefaultMigrationExecutor
75
- from amsdal_models.migration.file_migration_generator import FileMigrationGenerator
75
+ from amsdal_models.migration.file_migration_generator import BaseFileMigrationGenerator
76
76
  from amsdal_models.migration.file_migration_writer import FileMigrationWriter
77
77
  from amsdal_models.migration.migrations import MigrationSchemas
78
78
  from amsdal_models.schemas.class_schema_loader import ClassSchemaLoader
@@ -88,7 +88,7 @@ def _migrate_models(config_path: Path) -> None:
88
88
  new_manager = AmsdalManager()
89
89
  if not new_manager.is_setup:
90
90
  new_manager.setup()
91
- new_manager.post_setup()
91
+ new_manager.post_setup() # type: ignore[call-arg]
92
92
 
93
93
  schemas = MigrationSchemas()
94
94
  executor = DefaultMigrationExecutor(schemas, use_foreign_keys=True)
@@ -121,7 +121,7 @@ def _migrate_models(config_path: Path) -> None:
121
121
  _schemas_map = {_schema.title: _schema for _schema in _schemas}
122
122
 
123
123
  for object_schema in _schemas:
124
- for _operation_data in FileMigrationGenerator.build_operations(
124
+ for _operation_data in BaseFileMigrationGenerator.build_operations(
125
125
  ModuleType.USER,
126
126
  object_schema,
127
127
  None,
@@ -136,7 +136,7 @@ def _migrate_models(config_path: Path) -> None:
136
136
  _operation.forward(executor)
137
137
 
138
138
  for object_schema in _cycle_schemas:
139
- for _operation_data in FileMigrationGenerator.build_operations(
139
+ for _operation_data in BaseFileMigrationGenerator.build_operations(
140
140
  ModuleType.USER,
141
141
  object_schema,
142
142
  _schemas_map[object_schema.title],
@@ -163,7 +163,7 @@ async def _async_migrate_models(config_path: Path) -> None:
163
163
  from amsdal_models.classes.class_loader import ModelClassLoader
164
164
  from amsdal_models.migration import migrations
165
165
  from amsdal_models.migration.executors.default_executor import DefaultAsyncMigrationExecutor
166
- from amsdal_models.migration.file_migration_generator import AsyncFileMigrationGenerator
166
+ from amsdal_models.migration.file_migration_generator import BaseFileMigrationGenerator
167
167
  from amsdal_models.migration.file_migration_writer import FileMigrationWriter
168
168
  from amsdal_models.migration.migrations import MigrationSchemas
169
169
  from amsdal_models.schemas.class_schema_loader import ClassSchemaLoader
@@ -178,7 +178,7 @@ async def _async_migrate_models(config_path: Path) -> None:
178
178
  new_manager = AsyncAmsdalManager()
179
179
  if not new_manager.is_setup:
180
180
  await new_manager.setup()
181
- await new_manager.post_setup()
181
+ await new_manager.post_setup() # type: ignore[call-arg, misc]
182
182
 
183
183
  schemas = MigrationSchemas()
184
184
  executor = DefaultAsyncMigrationExecutor(schemas, use_foreign_keys=True)
@@ -211,7 +211,7 @@ async def _async_migrate_models(config_path: Path) -> None:
211
211
  _schemas_map = {_schema.title: _schema for _schema in _schemas}
212
212
 
213
213
  for object_schema in _schemas:
214
- for _operation_data in AsyncFileMigrationGenerator.build_operations(
214
+ for _operation_data in BaseFileMigrationGenerator.build_operations(
215
215
  ModuleType.USER,
216
216
  object_schema,
217
217
  None,
@@ -226,7 +226,7 @@ async def _async_migrate_models(config_path: Path) -> None:
226
226
  _operation.forward(executor)
227
227
 
228
228
  for object_schema in _cycle_schemas:
229
- for _operation_data in AsyncFileMigrationGenerator.build_operations(
229
+ for _operation_data in BaseFileMigrationGenerator.build_operations(
230
230
  ModuleType.USER,
231
231
  object_schema,
232
232
  _schemas_map[object_schema.title],
@@ -257,7 +257,7 @@ def _migrate_data(new_connection_name: str) -> None:
257
257
  origin_manager = AmsdalManager()
258
258
  if not origin_manager.is_setup:
259
259
  origin_manager.setup()
260
- origin_manager.post_setup()
260
+ origin_manager.post_setup() # type: ignore[call-arg]
261
261
 
262
262
  model_class_loader = ModelClassLoader(settings.USER_MODELS_MODULE)
263
263
  tables_for_connection = _resolve_tables_for_connection(new_connection_name)
@@ -310,7 +310,7 @@ async def _async_migrate_data(new_connection_name: str) -> None:
310
310
  origin_manager = AsyncAmsdalManager()
311
311
  if not origin_manager.is_setup:
312
312
  await origin_manager.setup()
313
- await origin_manager.post_setup()
313
+ await origin_manager.post_setup() # type: ignore[call-arg, misc]
314
314
 
315
315
  model_class_loader = ModelClassLoader(settings.USER_MODELS_MODULE)
316
316
  tables_for_connection = _resolve_tables_for_connection(new_connection_name)
@@ -346,7 +346,7 @@ async def _async_migrate_data(new_connection_name: str) -> None:
346
346
  force_insert = True
347
347
  lakehouse_item = model_class(**item.model_dump_refs())
348
348
 
349
- await lakehouse_item.asave(
349
+ await lakehouse_item.asave( # type: ignore[misc]
350
350
  force_insert=force_insert,
351
351
  using=LAKEHOUSE_DB_ALIAS,
352
352
  )
@@ -45,7 +45,7 @@ async def _async_serve(
45
45
  async def on_event_async(self, *args: Any, **kwargs: Any) -> None: # noqa: ARG002
46
46
  if not amsdal_manager._is_setup:
47
47
  await amsdal_manager.setup()
48
- await amsdal_manager.post_setup()
48
+ await amsdal_manager.post_setup() # type: ignore[call-arg, misc]
49
49
 
50
50
  if not amsdal_manager.is_authenticated:
51
51
  amsdal_manager.authenticate()
@@ -159,7 +159,7 @@ def serve_command(
159
159
  def on_event(self, *args: Any, **kwargs: Any) -> None: # noqa: ARG002
160
160
  if not amsdal_manager._is_setup:
161
161
  amsdal_manager.setup()
162
- amsdal_manager.post_setup()
162
+ amsdal_manager.post_setup() # type: ignore[call-arg]
163
163
 
164
164
  if not amsdal_manager.is_authenticated:
165
165
  amsdal_manager.authenticate()
@@ -122,13 +122,13 @@ def build_app_and_check_migrations(
122
122
  if not amsdal_manager.is_setup:
123
123
  amsdal_manager.setup()
124
124
 
125
- amsdal_manager.post_setup()
125
+ amsdal_manager.post_setup() # type: ignore[call-arg]
126
126
  amsdal_manager.init_classes()
127
127
 
128
128
  if not amsdal_manager.is_authenticated:
129
129
  amsdal_manager.authenticate()
130
130
 
131
- amsdal_manager.apply_fixtures()
131
+ amsdal_manager.apply_fixtures() # type: ignore[call-arg]
132
132
  rprint(rich_success('OK!'))
133
133
 
134
134
  return amsdal_manager
@@ -158,7 +158,7 @@ def check_migrations_generated_and_applied(
158
158
  if not amsdal_manager.is_authenticated:
159
159
  amsdal_manager.authenticate()
160
160
 
161
- amsdal_manager.post_setup()
161
+ amsdal_manager.post_setup() # type: ignore[call-arg]
162
162
 
163
163
  has_unapplied_migrations = _check_has_unapplied_migrations(build_dir=build_dir)
164
164
 
@@ -175,7 +175,6 @@ def _check_migrations_generated_and_applied(
175
175
  from amsdal.configs.constants import CORE_MIGRATIONS_PATH
176
176
  from amsdal.configs.main import settings
177
177
  from amsdal_models.migration.file_migration_generator import FileMigrationGenerator
178
- from amsdal_utils.models.enums import ModuleType
179
178
 
180
179
  from amsdal_cli.commands.generate.enums import SOURCES_DIR
181
180
  from amsdal_cli.commands.migrations.constants import MIGRATIONS_DIR_NAME
@@ -192,10 +191,11 @@ def _check_migrations_generated_and_applied(
192
191
  generator = FileMigrationGenerator(
193
192
  core_migrations_path=CORE_MIGRATIONS_PATH,
194
193
  app_migrations_path=migrations_dir,
195
- contrib_migrations_directory_name=settings.CONTRIB_MODELS_PACKAGE_NAME,
194
+ contrib_migrations_directory_name=settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
196
195
  )
196
+ generator.init_state()
197
197
 
198
- operations = generator.generate_operations(schemas=schema_repository.user_schemas, module_type=ModuleType.USER)
198
+ operations = generator.app_file_migration_generator.generate_operations(schemas=schema_repository.user_schemas)
199
199
 
200
200
  if operations:
201
201
  rprint(
@@ -216,6 +216,7 @@ def _check_has_unapplied_migrations(
216
216
  from amsdal_models.migration.base_migration_schemas import DefaultMigrationSchemas
217
217
  from amsdal_models.migration.file_migration_store import FileMigrationStore
218
218
  from amsdal_models.migration.migrations_loader import MigrationsLoader
219
+ from amsdal_models.migration.utils import build_migrations_module_name
219
220
  from amsdal_models.migration.utils import contrib_to_module_root_path
220
221
  from amsdal_utils.models.enums import ModuleType
221
222
 
@@ -226,6 +227,10 @@ def _check_has_unapplied_migrations(
226
227
  core_loader = MigrationsLoader(
227
228
  migrations_dir=CORE_MIGRATIONS_PATH,
228
229
  module_type=ModuleType.CORE,
230
+ module_name=build_migrations_module_name(
231
+ 'amsdal',
232
+ '__migrations__',
233
+ ),
229
234
  )
230
235
 
231
236
  schemas = DefaultMigrationSchemas()
@@ -238,9 +243,12 @@ def _check_has_unapplied_migrations(
238
243
 
239
244
  if _check_has_unapplied_migrations_per_loader(
240
245
  MigrationsLoader(
241
- migrations_dir=contrib_root_path / settings.MIGRATIONS_DIRECTORY_NAME,
246
+ migrations_dir=contrib_root_path / settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
242
247
  module_type=ModuleType.CONTRIB,
243
- module_name=contrib,
248
+ module_name=build_migrations_module_name(
249
+ '.'.join(contrib.split('.')[:-2]),
250
+ settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
251
+ ),
244
252
  ),
245
253
  all_applied_migrations,
246
254
  schemas,
@@ -251,6 +259,10 @@ def _check_has_unapplied_migrations(
251
259
  MigrationsLoader(
252
260
  migrations_dir=build_dir / MIGRATIONS_DIR_NAME,
253
261
  module_type=ModuleType.USER,
262
+ module_name=build_migrations_module_name(
263
+ None,
264
+ MIGRATIONS_DIR_NAME,
265
+ ),
254
266
  ),
255
267
  all_applied_migrations,
256
268
  schemas,
@@ -263,7 +275,7 @@ def _check_has_unapplied_migrations_per_loader(
263
275
  schemas: 'DefaultMigrationSchemas',
264
276
  ) -> bool:
265
277
  from amsdal_models.migration.executors.state_executor import StateMigrationExecutor
266
- from amsdal_models.migration.file_migration_executor import FileMigrationExecutorManager
278
+ from amsdal_models.migration.file_migration_executor import BaseMigrationExecutorManager
267
279
  from amsdal_models.migration.migrations import MigrateData
268
280
 
269
281
  from amsdal_cli.utils.text import rich_warning
@@ -278,7 +290,8 @@ def _check_has_unapplied_migrations_per_loader(
278
290
  return True
279
291
  else:
280
292
  # Register classes from migrations
281
- migration_class = FileMigrationExecutorManager.get_migration_class(_migration)
293
+
294
+ migration_class = BaseMigrationExecutorManager.get_migration_class(_migration)
282
295
  migration_class_instance = migration_class()
283
296
  state_executor = StateMigrationExecutor(
284
297
  schemas,
@@ -297,12 +310,15 @@ def _is_migration_applied(
297
310
  migration: 'MigrationFile',
298
311
  all_applied_migrations: list['MigrationFile'],
299
312
  ) -> bool:
313
+ from amsdal_models.migration.data_classes import ModuleType
314
+
300
315
  for applied_migration in all_applied_migrations:
301
- if (
302
- migration.type == applied_migration.type
303
- and migration.number == applied_migration.number
304
- and migration.module == applied_migration.module
305
- ):
316
+ is_applied = migration.type == applied_migration.type and migration.number == applied_migration.number
317
+
318
+ if migration.type == ModuleType.CONTRIB.value:
319
+ is_applied = is_applied and migration.module == applied_migration.module
320
+
321
+ if is_applied:
306
322
  return True
307
323
  return False
308
324
 
@@ -382,13 +398,13 @@ async def async_build_app_and_check_migrations(
382
398
  if not amsdal_manager.is_setup:
383
399
  await amsdal_manager.setup()
384
400
 
385
- await amsdal_manager.post_setup()
401
+ await amsdal_manager.post_setup() # type: ignore[call-arg,misc]
386
402
  amsdal_manager.init_classes()
387
403
 
388
404
  if not amsdal_manager.is_authenticated:
389
405
  amsdal_manager.authenticate()
390
406
 
391
- await amsdal_manager.apply_fixtures()
407
+ await amsdal_manager.apply_fixtures() # type: ignore[call-arg,misc]
392
408
  rprint(rich_success('OK!'))
393
409
  except Exception:
394
410
  if amsdal_manager.is_setup:
@@ -423,7 +439,7 @@ async def async_check_migrations_generated_and_applied(
423
439
  if not amsdal_manager.is_authenticated:
424
440
  amsdal_manager.authenticate()
425
441
 
426
- await amsdal_manager.post_setup()
442
+ await amsdal_manager.post_setup() # type: ignore[call-arg,misc]
427
443
 
428
444
  has_unapplied_migrations = await _async_check_has_unapplied_migrations(build_dir=build_dir)
429
445
 
@@ -441,6 +457,7 @@ async def _async_check_has_unapplied_migrations(
441
457
  from amsdal_models.migration.base_migration_schemas import DefaultMigrationSchemas
442
458
  from amsdal_models.migration.file_migration_store import AsyncFileMigrationStore
443
459
  from amsdal_models.migration.migrations_loader import MigrationsLoader
460
+ from amsdal_models.migration.utils import build_migrations_module_name
444
461
  from amsdal_models.migration.utils import contrib_to_module_root_path
445
462
  from amsdal_utils.models.enums import ModuleType
446
463
 
@@ -451,6 +468,10 @@ async def _async_check_has_unapplied_migrations(
451
468
  core_loader = MigrationsLoader(
452
469
  migrations_dir=CORE_MIGRATIONS_PATH,
453
470
  module_type=ModuleType.CORE,
471
+ module_name=build_migrations_module_name(
472
+ 'amsdal',
473
+ '__migrations__',
474
+ ),
454
475
  )
455
476
  schemas = DefaultMigrationSchemas()
456
477
 
@@ -462,9 +483,12 @@ async def _async_check_has_unapplied_migrations(
462
483
 
463
484
  if _check_has_unapplied_migrations_per_loader(
464
485
  MigrationsLoader(
465
- migrations_dir=contrib_root_path / settings.MIGRATIONS_DIRECTORY_NAME,
486
+ migrations_dir=contrib_root_path / settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
466
487
  module_type=ModuleType.CONTRIB,
467
- module_name=contrib,
488
+ module_name=build_migrations_module_name(
489
+ '.'.join(contrib.split('.')[:-2]),
490
+ settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
491
+ ),
468
492
  ),
469
493
  all_applied_migrations,
470
494
  schemas,
@@ -475,6 +499,10 @@ async def _async_check_has_unapplied_migrations(
475
499
  MigrationsLoader(
476
500
  migrations_dir=build_dir / MIGRATIONS_DIR_NAME,
477
501
  module_type=ModuleType.USER,
502
+ module_name=build_migrations_module_name(
503
+ None,
504
+ MIGRATIONS_DIR_NAME,
505
+ ),
478
506
  ),
479
507
  all_applied_migrations,
480
508
  schemas,
@@ -488,7 +516,6 @@ async def _async_check_migrations_generated_and_applied(
488
516
  from amsdal.configs.constants import CORE_MIGRATIONS_PATH
489
517
  from amsdal.configs.main import settings
490
518
  from amsdal_models.migration.file_migration_generator import AsyncFileMigrationGenerator
491
- from amsdal_utils.models.enums import ModuleType
492
519
 
493
520
  from amsdal_cli.commands.generate.enums import SOURCES_DIR
494
521
  from amsdal_cli.commands.migrations.constants import MIGRATIONS_DIR_NAME
@@ -505,11 +532,11 @@ async def _async_check_migrations_generated_and_applied(
505
532
  generator = AsyncFileMigrationGenerator(
506
533
  core_migrations_path=CORE_MIGRATIONS_PATH,
507
534
  app_migrations_path=migrations_dir,
508
- contrib_migrations_directory_name=settings.CONTRIB_MODELS_PACKAGE_NAME,
535
+ contrib_migrations_directory_name=settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
509
536
  )
510
- operations = await generator.generate_operations(
537
+ await generator.init_state()
538
+ operations = generator.app_file_migration_generator.generate_operations(
511
539
  schemas=schema_repository.user_schemas,
512
- module_type=ModuleType.USER,
513
540
  )
514
541
 
515
542
  if operations:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amsdal_cli
3
- Version: 0.4.16
3
+ Version: 0.5.1
4
4
  Summary: CLI for AMSDAL framework
5
5
  Project-URL: Documentation, https://pypi.org/project/amsdal_cli/#readme
6
6
  Project-URL: Issues, https://pypi.org/project/amsdal_cli/
@@ -121,7 +121,7 @@ Classifier: Programming Language :: Python :: 3.12
121
121
  Classifier: Programming Language :: Python :: Implementation :: CPython
122
122
  Classifier: Programming Language :: Python :: Implementation :: PyPy
123
123
  Requires-Python: >=3.11
124
- Requires-Dist: amsdal-server==0.4.*
124
+ Requires-Dist: amsdal-server==0.5.*
125
125
  Requires-Dist: click<8.2.0
126
126
  Requires-Dist: faker==27.*
127
127
  Requires-Dist: gitpython~=3.1
@@ -1,5 +1,5 @@
1
1
  amsdal_cli/Third-Party Materials - AMSDAL Dependencies - License Notices.md,sha256=uHJlGG0D4tbpUi8cq-497NNO9ltQ67a5448k-T14HTw,68241
2
- amsdal_cli/__about__.py,sha256=CNkKcTivBzCdpiOZg2Fy-UDtB7Hu79U3tfy8RCNecAQ,125
2
+ amsdal_cli/__about__.py,sha256=8T_uBHVYswzzhu1l92_ZGiaOtk_9NzrS_TQ0P-bqbf8,124
3
3
  amsdal_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  amsdal_cli/app.py,sha256=_ucuLT5ospf1ifFKEG0IMfVnxKjnvPUQ4iMhkvOfCrc,466
5
5
  amsdal_cli/main.py,sha256=LtH-BD1eJrAUecjKzC8Gx7kYFUstOMH1erdeJUVqFB8,144
@@ -32,7 +32,7 @@ amsdal_cli/commands/build/schemas/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5J
32
32
  amsdal_cli/commands/build/schemas/utils/merger.py,sha256=8dlSV3qgGAGNbOtGGx8zQ7yC99dihxg8JwPHMDboU2w,2229
33
33
  amsdal_cli/commands/build/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  amsdal_cli/commands/build/services/builder.py,sha256=vdR5rqJvjJjfrAAqkFNfnF6MUr4Nai5K_gxyvCQa8mw,3220
35
- amsdal_cli/commands/build/services/mixin.py,sha256=w8tMH7KOAypoV85fDD9xe9tdo3VCsgHj08nwrmnKAIY,5723
35
+ amsdal_cli/commands/build/services/mixin.py,sha256=KdjyrB0CaFQWIU9AZ6Z63tmfIEX5ZEo5HKD32KemDMQ,5749
36
36
  amsdal_cli/commands/build/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  amsdal_cli/commands/build/utils/build_config_file.py,sha256=65s3rP_nnr5FJLQlYStGF2JNYxExq5tWZvIU_h8Ae7I,2009
38
38
  amsdal_cli/commands/ci_cd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -58,7 +58,7 @@ amsdal_cli/commands/cloud/deploy/command.py,sha256=LIX07pTU55GUA9KmTiKDtoCj5Ytx9
58
58
  amsdal_cli/commands/cloud/deploy/sub_commands/__init__.py,sha256=I7MJEyceCIgCXP7JpX06nLvEA6HUkjj9LSDAb7VfTGo,353
59
59
  amsdal_cli/commands/cloud/deploy/sub_commands/deploy_delete.py,sha256=pRLumeigF4e_Nod32p6XkgJsYxbB9H3WSxbv0IwA5Eo,3221
60
60
  amsdal_cli/commands/cloud/deploy/sub_commands/deploy_list.py,sha256=Nm-uaAmCjLP9UDFNM-E79QLAiqy6_9VQSTd_W8bKoE0,5532
61
- amsdal_cli/commands/cloud/deploy/sub_commands/deploy_new.py,sha256=FTcILPoesHXGvZlsax8VivKE3Ghw63fKK1EAIenSoWU,12718
61
+ amsdal_cli/commands/cloud/deploy/sub_commands/deploy_new.py,sha256=G28mt1cMv8js80FTtzxahCCWV8AVcu7BWe4w7Nqvp04,12748
62
62
  amsdal_cli/commands/cloud/environments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  amsdal_cli/commands/cloud/environments/app.py,sha256=kkzf_kW2jpl3d44qWuIZB5C3uWXzpNpnTIvUpuuPJHE,238
64
64
  amsdal_cli/commands/cloud/environments/command.py,sha256=roeg2tpa53W1qzCa_3-zEn5z2xiVS4STWB9M7P5BVKA,283
@@ -104,7 +104,7 @@ amsdal_cli/commands/generate/enums.py,sha256=4Nvbe4aJEUOMkFqjNbr2xtnvzqrJEh2qDiw
104
104
  amsdal_cli/commands/generate/sub_commands/__init__.py,sha256=WyZ4kE6IH9O_igOVJ31UQtqE12cCKyATi4E-qgslN3k,941
105
105
  amsdal_cli/commands/generate/sub_commands/generate_frontend_config.py,sha256=SkEzx7-mWgrPINwPXGRmYO1SVA0RZojOd6BZFQRmG0Q,2574
106
106
  amsdal_cli/commands/generate/sub_commands/generate_hook.py,sha256=C0Oy5VokM3BXPq33Kknjvtjwd7hdfSxQFKxJcHu_bgg,1738
107
- amsdal_cli/commands/generate/sub_commands/generate_model.py,sha256=5IgbkMqPHBBHIBZm5PzLJjl4lN9eyR89CT-yEtH63Ms,5909
107
+ amsdal_cli/commands/generate/sub_commands/generate_model.py,sha256=imUNWHS0YgJLC1dNRi_Q6k5FfiUIAHDWf-wMHFk6Ucg,5879
108
108
  amsdal_cli/commands/generate/sub_commands/generate_modifier.py,sha256=NyN7vMTBGaQv6u815WT1lqAlqI4xP1AmIZWq5edZ-5g,1426
109
109
  amsdal_cli/commands/generate/sub_commands/generate_permission.py,sha256=gfRhZsnNnd_m_HxdOCB8C22tbMkopg2FTKo-T68b13s,2824
110
110
  amsdal_cli/commands/generate/sub_commands/generate_property.py,sha256=XrCjf48oEzuMPqsTuC5Qsn1WbIQzUVW8BNOmXssfUM8,1599
@@ -135,9 +135,9 @@ amsdal_cli/commands/migrations/app.py,sha256=0HsKjZ5D2j9xkOi2Fuvs3VdlhWyQnS8XJ6p
135
135
  amsdal_cli/commands/migrations/command.py,sha256=jlpdYZAc02ZUBxSdzGSzkDxEb1nlHNzoq05FdRCSzus,206
136
136
  amsdal_cli/commands/migrations/constants.py,sha256=846-DQ-Iqcxw2akd5aBAmbnXHDmRFqEKu6vai2ZFBkU,35
137
137
  amsdal_cli/commands/migrations/sub_commands/__init__.py,sha256=_rWbDyY3DPdN-6vE60djCtHejvSkl6d1e2Z4ScM52bo,976
138
- amsdal_cli/commands/migrations/sub_commands/apply.py,sha256=S7gfkxhOfcjfXiBiiwH9dVMVrMmedlwe_SaMBS-YaD4,9497
139
- amsdal_cli/commands/migrations/sub_commands/list.py,sha256=xOfonot6JAs3ApXe-QRLKfJf2kVsj7TalEMwK3V_uC4,5439
140
- amsdal_cli/commands/migrations/sub_commands/make.py,sha256=fLw4iC5lRxdksxg3yaf-qh0yPBNNlvfrdIZ-xxYG3Lk,6258
138
+ amsdal_cli/commands/migrations/sub_commands/apply.py,sha256=FmkdIE5RUrCCkLJVgM3rtLva-4rYkKlzbjanOQqadUQ,9744
139
+ amsdal_cli/commands/migrations/sub_commands/list.py,sha256=cskcdftYy-u-_rH1iPhreTQv_XiGD42bwi3vQCVe8to,6188
140
+ amsdal_cli/commands/migrations/sub_commands/make.py,sha256=5DiSp5j_iv1Mk7eVFRJ_yCVdc1lZGkctmtY-tNbqaTk,6322
141
141
  amsdal_cli/commands/new/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
142
142
  amsdal_cli/commands/new/command.py,sha256=NDuDZNwreyuHsv4tbE-yrNOJViB8wk35IcKvGKQXPXo,3302
143
143
  amsdal_cli/commands/new/templates/.amsdal-cli,sha256=PdXPovcT8AfPhqwDLI_4EWFYAS6e3J5JcsHVityBdF8,304
@@ -154,17 +154,17 @@ amsdal_cli/commands/register_connection/utils/__init__.py,sha256=47DEQpj8HBSa-_T
154
154
  amsdal_cli/commands/register_connection/utils/build.py,sha256=7aE9AqUyhGM10fOtgbHdCKo6JG5f4xrM1NnjbXTBxWA,762
155
155
  amsdal_cli/commands/register_connection/utils/config_updater.py,sha256=CDsaCuli5tCsHoNrzfeWoVDPlyOTWvi8TPdbM4Fzo4o,4204
156
156
  amsdal_cli/commands/register_connection/utils/credentials.py,sha256=iaAF5STbKJNIoT8vL30DafTn4uzYnrjumtM3XNHuOS8,1066
157
- amsdal_cli/commands/register_connection/utils/initialize.py,sha256=PMFoqAIxFB1xzY56FFX2-pRJ_CZbwUbgD25m0Pk1b48,1080
157
+ amsdal_cli/commands/register_connection/utils/initialize.py,sha256=9NvfAWOvWQVrSfVNZnGBqeKcQ7bxpTf56oj8239jgc8,1279
158
158
  amsdal_cli/commands/register_connection/utils/meta.py,sha256=PDs2miN0SPW2hCATLY8uGe1WOzDyw-D6my90P-mpcl8,709
159
- amsdal_cli/commands/register_connection/utils/migrate_models.py,sha256=XN7pPE7KsqEVcQzTCymIn7lIgX4n6UEZkv1v_HlBdgU,13902
159
+ amsdal_cli/commands/register_connection/utils/migrate_models.py,sha256=oU_5oZcwU-qIMImpFIGniXvs7CJXyCyfSJozhFBRYkM,14077
160
160
  amsdal_cli/commands/register_connection/utils/model_generator.py,sha256=w0vz-i-tMdimcQYmFbtfpOZJF8heTTRIzu1yTdbKBpc,10853
161
161
  amsdal_cli/commands/register_connection/utils/tables.py,sha256=FOwbWOpEw485Leoqe8LXCVY5osGKTKlMqWD9oqosapk,474
162
162
  amsdal_cli/commands/restore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
163
163
  amsdal_cli/commands/restore/command.py,sha256=DZ27U8BXkMsxhiqYfQ64wduC-0UYq7UPcZfYRHgZ8nA,36004
164
164
  amsdal_cli/commands/restore/enums.py,sha256=6SiKMRGlSjiLyepfbfQFXGAYqlM6Bkoeko2KscntTUQ,307
165
165
  amsdal_cli/commands/serve/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
166
- amsdal_cli/commands/serve/command.py,sha256=tjm1T0yrA2P6nlk_KDNv6Gih2Dkt5nMIN-_WUrLhn58,6541
167
- amsdal_cli/commands/serve/utils.py,sha256=h-t6trB0nf7bJyz2vU42AQYdbi5DDmF3qHwtqb5R_Yc,17381
166
+ amsdal_cli/commands/serve/command.py,sha256=x1_8gZDhRCUQt2-8v1K7__2uPjIlte_tY1ctJxVbl4k,6599
167
+ amsdal_cli/commands/serve/utils.py,sha256=GhUxSdNN2eX8XbzVtl6IdAcMUY_UdozHKkoCVgaTVKs,18613
168
168
  amsdal_cli/commands/serve/filters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
169
169
  amsdal_cli/commands/serve/filters/models_watch_filter.py,sha256=cnoAjrn-PYDAFq5MtgbQ6QeCvJJmcNisVNlA8QtFv4A,170
170
170
  amsdal_cli/commands/serve/filters/static_files_watch_filter.py,sha256=jKAF5RHq1au2v0kcOrqaAHP1x5IUjt_KgZURJLm29Tw,552
@@ -199,8 +199,8 @@ amsdal_cli/utils/vcs/base.py,sha256=jC05ExJZDnyHAsW7_4IDf8gQcYgK4dXq3zNlFIX66T4,
199
199
  amsdal_cli/utils/vcs/dummy.py,sha256=Lk8MT-b0YlHHUsiXsq5cvmPwcl4jTYdo8piN5_C8ORA,434
200
200
  amsdal_cli/utils/vcs/enums.py,sha256=tYR9LN1IOr8BZFbSeX_vDlhn8fPl4IU-Yakii8lRDYs,69
201
201
  amsdal_cli/utils/vcs/git.py,sha256=xHynbZcV6p2D3RFCwu1MGGpV9D7eK-pGUtO8kVexTQM,1269
202
- amsdal_cli-0.4.16.dist-info/METADATA,sha256=TW0S3whObzI_H5FKzypEkSk53wd4IYvTX3jOoPCIs0s,57077
203
- amsdal_cli-0.4.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
204
- amsdal_cli-0.4.16.dist-info/entry_points.txt,sha256=GC-8LZsD3W--Pd9_gD4W3tw3ZZyPbSvkZ-qWc9Fx0NI,47
205
- amsdal_cli-0.4.16.dist-info/licenses/LICENSE.txt,sha256=hG-541PFYfNJi9WRZi_hno91UyqNg7YLK8LR3vLblZA,27355
206
- amsdal_cli-0.4.16.dist-info/RECORD,,
202
+ amsdal_cli-0.5.1.dist-info/METADATA,sha256=f2hWFH9YPPht0n1YdpChdC7oDrRbzmSv0zSUbbC5VwI,57076
203
+ amsdal_cli-0.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
204
+ amsdal_cli-0.5.1.dist-info/entry_points.txt,sha256=GC-8LZsD3W--Pd9_gD4W3tw3ZZyPbSvkZ-qWc9Fx0NI,47
205
+ amsdal_cli-0.5.1.dist-info/licenses/LICENSE.txt,sha256=hG-541PFYfNJi9WRZi_hno91UyqNg7YLK8LR3vLblZA,27355
206
+ amsdal_cli-0.5.1.dist-info/RECORD,,