From f819153fd2307dec35fc4085b7e11bc7772675f6 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 1 Feb 2024 12:28:41 -0600 Subject: Initial commit --- ...7a92bef47675_add_unique_constraint_to_domain.py | 32 ++++++++++++++++++++ migrations/versions/e2f6c7622c68_add_blogs.py | 34 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 migrations/versions/7a92bef47675_add_unique_constraint_to_domain.py create mode 100644 migrations/versions/e2f6c7622c68_add_blogs.py (limited to 'migrations/versions') diff --git a/migrations/versions/7a92bef47675_add_unique_constraint_to_domain.py b/migrations/versions/7a92bef47675_add_unique_constraint_to_domain.py new file mode 100644 index 0000000..c915ab5 --- /dev/null +++ b/migrations/versions/7a92bef47675_add_unique_constraint_to_domain.py @@ -0,0 +1,32 @@ +"""Add unique constraint to domain + +Revision ID: 7a92bef47675 +Revises: e2f6c7622c68 +Create Date: 2024-02-01 12:16:13.397739 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '7a92bef47675' +down_revision = 'e2f6c7622c68' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('blogs', schema=None) as batch_op: + batch_op.create_unique_constraint(None, ['domain']) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('blogs', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='unique') + + # ### end Alembic commands ### diff --git a/migrations/versions/e2f6c7622c68_add_blogs.py b/migrations/versions/e2f6c7622c68_add_blogs.py new file mode 100644 index 0000000..9c76d5d --- /dev/null +++ b/migrations/versions/e2f6c7622c68_add_blogs.py @@ -0,0 +1,34 @@ +"""Add Blogs + +Revision ID: e2f6c7622c68 +Revises: +Create Date: 2024-02-01 11:58:22.590819 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'e2f6c7622c68' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('blogs', + sa.Column('id', sa.BigInteger(), nullable=False), + sa.Column('domain', sa.String(length=255), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('blogs') + # ### end Alembic commands ### -- cgit v1.2.3