-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
0cfdae3
commit 30a0977
Showing
3 changed files
with
50 additions
and
40 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 |
---|---|---|
@@ -1,56 +1,66 @@ | ||
"""init_v2 | ||
Revision ID: 5449fbd7e244 | ||
Revises: | ||
Revises: | ||
Create Date: 2024-12-25 14:23:56.622802 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from aggregator.models import NOT_SPECIFIED_CHANNEL_TYPE | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '5449fbd7e244' | ||
revision: str = "5449fbd7e244" | ||
down_revision: Union[str, None] = None | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.create_table('channel_type', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('type_', sa.String(), nullable=False), | ||
sa.PrimaryKeyConstraint('id'), | ||
sa.UniqueConstraint('type_') | ||
) | ||
op.create_table('channel', | ||
sa.Column('id', sa.BigInteger(), nullable=False), | ||
sa.Column('type_id', sa.Integer(), nullable=True), | ||
sa.Column('name', sa.String(), nullable=True), | ||
sa.ForeignKeyConstraint(['type_id'], ['channel_type.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_table('message', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('message_id', sa.Integer(), nullable=False), | ||
sa.Column('grouped_id', sa.BigInteger(), nullable=True), | ||
sa.Column('sent', sa.DateTime(), nullable=True), | ||
sa.Column('channel_id', sa.BigInteger(), nullable=False), | ||
sa.Column('original_channel_id', sa.BigInteger(), nullable=False), | ||
sa.Column('original_message_id', sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint(['channel_id'], ['channel.id'], ), | ||
sa.PrimaryKeyConstraint('id'), | ||
sa.UniqueConstraint('original_channel_id', 'original_message_id', name='source_message_uniq') | ||
) | ||
op.execute("INSERT INTO public.channel_type (id, type_)" | ||
f"VALUES (0, '{NOT_SPECIFIED_CHANNEL_TYPE}')") | ||
op.create_table( | ||
"channel_type", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("type_", sa.String(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("type_"), | ||
) | ||
op.create_table( | ||
"channel", | ||
sa.Column("id", sa.BigInteger(), nullable=False), | ||
sa.Column("type_id", sa.Integer(), nullable=True), | ||
sa.Column("name", sa.String(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["type_id"], | ||
["channel_type.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"message", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("message_id", sa.Integer(), nullable=False), | ||
sa.Column("grouped_id", sa.BigInteger(), nullable=True), | ||
sa.Column("sent", sa.DateTime(), nullable=True), | ||
sa.Column("channel_id", sa.BigInteger(), nullable=False), | ||
sa.Column("original_channel_id", sa.BigInteger(), nullable=False), | ||
sa.Column("original_message_id", sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["channel_id"], | ||
["channel.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("original_channel_id", "original_message_id", name="source_message_uniq"), | ||
) | ||
op.execute("INSERT INTO public.channel_type (id, type_)" f"VALUES (0, '{NOT_SPECIFIED_CHANNEL_TYPE}')") | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('message') | ||
op.drop_table('channel') | ||
op.drop_table('channel_type') | ||
op.drop_table("message") | ||
op.drop_table("channel") | ||
op.drop_table("channel_type") | ||
# ### 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
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