|
| 1 | +"""remove_blogs |
| 2 | +
|
| 3 | +Revision ID: 13d2afe94e48 |
| 4 | +Revises: 6a56c28c6bf1 |
| 5 | +Create Date: 2022-09-06 17:29:55.189057 |
| 6 | +
|
| 7 | +""" |
| 8 | +from alembic import op |
| 9 | +import sqlalchemy as sa |
| 10 | +from sqlalchemy_searchable import drop_trigger |
| 11 | +import sqlalchemy_utils |
| 12 | +from sqlalchemy.dialects import postgresql |
| 13 | + |
| 14 | +# revision identifiers, used by Alembic. |
| 15 | +revision = '13d2afe94e48' |
| 16 | +down_revision = '6a56c28c6bf1' |
| 17 | +branch_labels = None |
| 18 | +depends_on = None |
| 19 | + |
| 20 | + |
| 21 | +def upgrade(): |
| 22 | + # ### commands auto generated by Alembic - please adjust! ### |
| 23 | + conn = op.get_bind() |
| 24 | + drop_trigger(conn, "blogs", "search_vector") |
| 25 | + op.drop_index('blogs_tags_array_idx', table_name='blogs') |
| 26 | + op.drop_table('blogs') |
| 27 | + # ### end Alembic commands ### |
| 28 | + |
| 29 | + |
| 30 | +def downgrade(): |
| 31 | + # ### commands auto generated by Alembic - please adjust! ### |
| 32 | + op.create_table('blogs', |
| 33 | + sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), |
| 34 | + sa.Column('title', sa.TEXT(), autoincrement=False, nullable=False), |
| 35 | + sa.Column('slug', sa.TEXT(), autoincrement=False, nullable=False), |
| 36 | + sa.Column('tags', postgresql.ARRAY(sa.TEXT()), autoincrement=False, nullable=False), |
| 37 | + sa.Column('content', sa.TEXT(), autoincrement=False, nullable=False), |
| 38 | + sa.Column('creation_date', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False), |
| 39 | + sa.Column('edit_date', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False), |
| 40 | + sa.Column('search_vector', postgresql.TSVECTOR(), autoincrement=False, nullable=True), |
| 41 | + sa.Column('author_id', sa.BIGINT(), autoincrement=False, nullable=True), |
| 42 | + sa.CheckConstraint("slug <> ''::text", name='blogs_slug_nonempty'), |
| 43 | + sa.ForeignKeyConstraint(['author_id'], ['users.discord_id'], name='blogs_author_id_fkey', ondelete='SET NULL'), |
| 44 | + sa.PrimaryKeyConstraint('id', name='blogs_pkey'), |
| 45 | + sa.UniqueConstraint('slug', name='blogs_slug_key'), |
| 46 | + sa.UniqueConstraint('title', name='blogs_title_key') |
| 47 | + ) |
| 48 | + op.create_index('blogs_tags_array_idx', 'blogs', ['tags'], unique=False) |
| 49 | + # ### end Alembic commands ### |
0 commit comments