-
Notifications
You must be signed in to change notification settings - Fork 31
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 (#743)
* feat: BI-5955 schema migration factory
- Loading branch information
1 parent
b5035a2
commit 230db12
Showing
11 changed files
with
103 additions
and
4 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 |
28 changes: 28 additions & 0 deletions
28
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,28 @@ | ||
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() |
13 changes: 13 additions & 0 deletions
13
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,13 @@ | ||
import abc | ||
|
||
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