-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: BI-5955 schema migration factory
- Loading branch information
1 parent
624c150
commit ac7a66a
Showing
11 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from dl_core.us_manager.schema_migration.base import ( | ||
BaseEntrySchemaMigration, | ||
Migration, | ||
) | ||
|
||
|
||
class ConnectionSchemaMigration(BaseEntrySchemaMigration): | ||
... | ||
|
||
|
||
class DefaultConnectionSchemaMigration(ConnectionSchemaMigration): | ||
@property | ||
def migrations(self) -> list[Migration]: | ||
migrations = [] | ||
migrations.extend(super().migrations) | ||
return migrations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
lib/dl_core/dl_core/us_manager/schema_migration/dataset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from dl_core.us_manager.schema_migration.base import ( | ||
BaseEntrySchemaMigration, | ||
Migration, | ||
) | ||
|
||
|
||
class DatasetSchemaMigration(BaseEntrySchemaMigration): | ||
@property | ||
def migrations(self) -> list[Migration]: | ||
migrations = [] | ||
migrations.extend(super().migrations) | ||
return migrations |
30 changes: 30 additions & 0 deletions
30
lib/dl_core/dl_core/us_manager/schema_migration/factory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from __future__ import annotations | ||
|
||
from dl_core.us_connection import get_schema_migration_cls | ||
from dl_core.us_manager.schema_migration.base import BaseEntrySchemaMigration | ||
from dl_core.us_manager.schema_migration.dataset import DatasetSchemaMigration | ||
from dl_core.us_manager.schema_migration.factory_base import EntrySchemaMigrationFactoryBase | ||
|
||
|
||
class DummyEntrySchemaMigrationFactory(EntrySchemaMigrationFactoryBase): | ||
def get_schema_migration( | ||
self, | ||
entry_scope: str, | ||
entry_type: str, | ||
) -> BaseEntrySchemaMigration: | ||
return BaseEntrySchemaMigration() | ||
|
||
|
||
class DefaultEntrySchemaMigrationFactory(EntrySchemaMigrationFactoryBase): | ||
def get_schema_migration( | ||
self, | ||
entry_scope: str, | ||
entry_type: str, | ||
) -> BaseEntrySchemaMigration: | ||
if entry_scope == "dataset": | ||
return DatasetSchemaMigration() | ||
elif entry_scope == "connection": | ||
schema_migration_cls = get_schema_migration_cls(conn_type_name=entry_type) | ||
return schema_migration_cls() | ||
else: | ||
return BaseEntrySchemaMigration() |
18 changes: 18 additions & 0 deletions
18
lib/dl_core/dl_core/us_manager/schema_migration/factory_base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
import abc | ||
from typing import TYPE_CHECKING | ||
|
||
|
||
if TYPE_CHECKING: | ||
from dl_core.us_manager.schema_migration.base import BaseEntrySchemaMigration | ||
|
||
|
||
class EntrySchemaMigrationFactoryBase(abc.ABC): | ||
@abc.abstractmethod | ||
def get_schema_migration( | ||
self, | ||
entry_scope: str, | ||
entry_type: str, | ||
) -> BaseEntrySchemaMigration: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters