-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from Pogchamp-company/develop
Version 1.6.0
- Loading branch information
Showing
13 changed files
with
264 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: psf/black@stable | ||
- uses: psf/black@25.1.0 |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
from .compare_dispatch import compare_enums | ||
from .compare_dispatch import compare_enums as _ | ||
from .get_enum_data import ColumnType, TableReference | ||
from .configuration import set_configuration, Config | ||
|
||
__all__ = ( | ||
"ColumnType", | ||
"TableReference", | ||
"set_configuration", | ||
"Config", | ||
) |
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
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
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,70 @@ | ||
from typing import Optional | ||
|
||
from sqlalchemy import MetaData, Table, Column, Integer | ||
from sqlalchemy.dialects import postgresql | ||
|
||
from tests.schemas import USER_TABLE_NAME, USER_STATUS_ENUM_NAME | ||
from tests.base.run_migration_test_abc import CompareAndRunTestCase | ||
|
||
|
||
class TestExoticColumnNameRender(CompareAndRunTestCase): | ||
"""https://github.com/Pogchamp-company/alembic-postgresql-enum/issues/95""" | ||
|
||
old_enum_variants = ["active", "passive"] | ||
new_enum_variants = old_enum_variants + ["banned"] | ||
|
||
def get_database_schema(self) -> MetaData: | ||
schema = MetaData() | ||
|
||
Table( | ||
USER_TABLE_NAME, | ||
schema, | ||
Column("id", Integer, primary_key=True), | ||
Column( | ||
"case", | ||
postgresql.ENUM(*self.old_enum_variants, name=USER_STATUS_ENUM_NAME), | ||
), | ||
) | ||
|
||
return schema | ||
|
||
def get_target_schema(self) -> MetaData: | ||
schema = MetaData() | ||
|
||
Table( | ||
USER_TABLE_NAME, | ||
schema, | ||
Column("id", Integer, primary_key=True), | ||
Column( | ||
"case", | ||
postgresql.ENUM(*self.new_enum_variants, name=USER_STATUS_ENUM_NAME), | ||
), | ||
) | ||
|
||
return schema | ||
|
||
def get_expected_upgrade(self) -> str: | ||
return f""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.sync_enum_values( | ||
enum_schema='public', | ||
enum_name='user_status', | ||
new_values=['active', 'passive', 'banned'], | ||
affected_columns=[TableReference(table_schema='public', table_name='users', column_name='case')], | ||
enum_values_to_rename=[], | ||
) | ||
# ### end Alembic commands ### | ||
""" | ||
|
||
def get_expected_downgrade(self) -> Optional[str]: | ||
return f""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.sync_enum_values( | ||
enum_schema='public', | ||
enum_name='user_status', | ||
new_values=['active', 'passive'], | ||
affected_columns=[TableReference(table_schema='public', table_name='users', column_name='case')], | ||
enum_values_to_rename=[], | ||
) | ||
# ### end Alembic commands ### | ||
""" |
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,71 @@ | ||
from typing import Optional | ||
|
||
from sqlalchemy import MetaData, Table, Column, Integer | ||
from sqlalchemy.dialects import postgresql | ||
|
||
from tests.schemas import USER_STATUS_COLUMN_NAME | ||
from tests.schemas import USER_TABLE_NAME | ||
from tests.base.run_migration_test_abc import CompareAndRunTestCase | ||
|
||
|
||
class TestExoticColumnNameRender(CompareAndRunTestCase): | ||
"""Test for enum names that are keyword in postgres""" | ||
|
||
old_enum_variants = ["active", "passive"] | ||
new_enum_variants = old_enum_variants + ["banned"] | ||
|
||
def get_database_schema(self) -> MetaData: | ||
schema = MetaData() | ||
|
||
Table( | ||
USER_TABLE_NAME, | ||
schema, | ||
Column("id", Integer, primary_key=True), | ||
Column( | ||
USER_STATUS_COLUMN_NAME, | ||
postgresql.ENUM(*self.old_enum_variants, name="type"), | ||
), | ||
) | ||
|
||
return schema | ||
|
||
def get_target_schema(self) -> MetaData: | ||
schema = MetaData() | ||
|
||
Table( | ||
USER_TABLE_NAME, | ||
schema, | ||
Column("id", Integer, primary_key=True), | ||
Column( | ||
USER_STATUS_COLUMN_NAME, | ||
postgresql.ENUM(*self.new_enum_variants, name="type"), | ||
), | ||
) | ||
|
||
return schema | ||
|
||
def get_expected_upgrade(self) -> str: | ||
return f""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.sync_enum_values( | ||
enum_schema='public', | ||
enum_name='type', | ||
new_values=['active', 'passive', 'banned'], | ||
affected_columns=[TableReference(table_schema='public', table_name='users', column_name='status')], | ||
enum_values_to_rename=[], | ||
) | ||
# ### end Alembic commands ### | ||
""" | ||
|
||
def get_expected_downgrade(self) -> Optional[str]: | ||
return f""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.sync_enum_values( | ||
enum_schema='public', | ||
enum_name='type', | ||
new_values=['active', 'passive'], | ||
affected_columns=[TableReference(table_schema='public', table_name='users', column_name='status')], | ||
enum_values_to_rename=[], | ||
) | ||
# ### end Alembic commands ### | ||
""" |
Oops, something went wrong.