Skip to content

Commit

Permalink
Merge pull request #68 from boris/fix-db-migrations
Browse files Browse the repository at this point in the history
Reset DB migrations
  • Loading branch information
boris authored Jan 24, 2024
2 parents af6d6d0 + f6f1a37 commit 5a20c9e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 35 deletions.
Binary file modified migrations/__pycache__/env.cpython-310.pyc
Binary file not shown.
96 changes: 96 additions & 0 deletions migrations/versions/7579ecdfb08c_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""empty message
Revision ID: 7579ecdfb08c
Revises:
Create Date: 2024-01-24 10:20:05.764648
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '7579ecdfb08c'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('author',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('country', sa.String(length=255), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('editorial',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('genre',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id', 'name')
)
op.create_table('quotes',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('quote', sa.Text(), nullable=False),
sa.Column('owner', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('tag',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id', 'name')
)
op.create_table('user',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('email', sa.String(length=100), nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('password_hash', sa.String(length=120), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
op.create_table('book',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('year', sa.Integer(), nullable=True),
sa.Column('pages', sa.Integer(), nullable=True),
sa.Column('read', sa.Boolean(), nullable=True),
sa.Column('shared', sa.Boolean(), nullable=True),
sa.Column('rating', sa.Integer(), nullable=True),
sa.Column('review', sa.Text(), nullable=True),
sa.Column('isbn', sa.String(length=255), nullable=True),
sa.Column('id_user', sa.Integer(), nullable=False),
sa.Column('id_author', sa.Integer(), nullable=False),
sa.Column('id_editorial', sa.Integer(), nullable=False),
sa.Column('id_genre', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['id_author'], ['author.id'], ),
sa.ForeignKeyConstraint(['id_editorial'], ['editorial.id'], ),
sa.ForeignKeyConstraint(['id_genre'], ['genre.id'], ),
sa.ForeignKeyConstraint(['id_user'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('books_tags',
sa.Column('id_tag', sa.Integer(), nullable=False),
sa.Column('id_book', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['id_book'], ['book.id'], ),
sa.ForeignKeyConstraint(['id_tag'], ['tag.id'], ),
sa.PrimaryKeyConstraint('id_tag', 'id_book')
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('books_tags')
op.drop_table('book')
op.drop_table('user')
op.drop_table('tag')
op.drop_table('quotes')
op.drop_table('genre')
op.drop_table('editorial')
op.drop_table('author')
# ### end Alembic commands ###
Binary file not shown.
Binary file not shown.
35 changes: 0 additions & 35 deletions migrations/versions/c832df1252a4_.py

This file was deleted.

0 comments on commit 5a20c9e

Please sign in to comment.