46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""empty message
|
|
|
|
Revision ID: df6187181c66
|
|
Revises: da6bc5b8d253
|
|
Create Date: 2020-08-19 04:51:24.137270
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'df6187181c66'
|
|
down_revision = 'da6bc5b8d253'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Заметка
|
|
op.create_table('note',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('title', sa.String(), nullable=True),
|
|
sa.Column('body', sa.String(), nullable=True),
|
|
sa.Column('created', sa.DateTime(), nullable=True),
|
|
sa.Column('updated', sa.DateTime(), nullable=True),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
|
|
# Теги к заметкам
|
|
op.create_table('tagnote',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('note_id', sa.Integer(), nullable=True),
|
|
sa.Column('tag_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['note_id'], ['note.id'], ),
|
|
sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_table("tagnote")
|
|
op.drop_table("note")
|