From 270345c59c787a7d0fa5c135c4a726557b84f5cc Mon Sep 17 00:00:00 2001 From: quaduzi Date: Tue, 20 Jun 2023 06:26:07 +0700 Subject: [PATCH] add migration --- .gitignore | 3 +- migrations/versions/75599d686560_post.py | 69 ++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/75599d686560_post.py diff --git a/.gitignore b/.gitignore index 8c43a5f..2cff3c1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ __pycache__/ .idea **/venv/ -.env-render \ No newline at end of file +.env-render +/src/tailwindcss/ diff --git a/migrations/versions/75599d686560_post.py b/migrations/versions/75599d686560_post.py new file mode 100644 index 0000000..6081b64 --- /dev/null +++ b/migrations/versions/75599d686560_post.py @@ -0,0 +1,69 @@ +"""post + +Revision ID: 75599d686560 +Revises: c5aff621ba6c +Create Date: 2023-06-19 23:18:01.064624 + +""" +from alembic import op +import sqlalchemy as sa +import sqlmodel + + +# revision identifiers, used by Alembic. +revision = '75599d686560' +down_revision = 'c5aff621ba6c' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('tag', + sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False), + sa.Column('id', sa.Integer(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('user', + sa.Column('username', sqlmodel.sql.sqltypes.AutoString(), nullable=False), + sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=True), + sa.Column('full_name', sqlmodel.sql.sqltypes.AutoString(), nullable=True), + sa.Column('disabled', sa.Boolean(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('hashed_password', sqlmodel.sql.sqltypes.AutoString(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('post', + sa.Column('text', sqlmodel.sql.sqltypes.AutoString(), nullable=False), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('author_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['author_id'], ['user.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('comment', + sa.Column('text', sqlmodel.sql.sqltypes.AutoString(), nullable=False), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('author_id', sa.Integer(), nullable=True), + sa.Column('post_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['author_id'], ['user.id'], ), + sa.ForeignKeyConstraint(['post_id'], ['post.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('posttaglink', + sa.Column('post_id', sa.Integer(), nullable=False), + sa.Column('tag_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['post_id'], ['post.id'], ), + sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ), + sa.PrimaryKeyConstraint('post_id', 'tag_id') + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('posttaglink') + op.drop_table('comment') + op.drop_table('post') + op.drop_table('user') + op.drop_table('tag') + # ### end Alembic commands ###