alembic/versions/08c9a177f639_notes_table.py
"""Notes table
Revision ID: 08c9a177f639
Revises: 4039aa74290f
Create Date: 2023-10-16 17:55:24.680025
"""
# revision identifiers, used by Alembic.
revision = '08c9a177f639'
down_revision = '4039aa74290f'
from alembic import op
import sqlalchemy as sa
import biblib
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('notes_version',
sa.Column('id', sa.Integer(), autoincrement=False, nullable=False),
sa.Column('content', sa.UnicodeText(), autoincrement=False, nullable=True),
sa.Column('bibcode', sa.String(length=19), autoincrement=False, nullable=True),
sa.Column('library_id', biblib.models.GUID(), autoincrement=False, nullable=True),
sa.Column('date_created', sa.DateTime(), autoincrement=False, nullable=True),
sa.Column('date_last_modified', sa.DateTime(), autoincrement=False, nullable=True),
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
sa.Column('end_transaction_id', sa.BigInteger(), nullable=True),
sa.Column('operation_type', sa.SmallInteger(), nullable=False),
sa.PrimaryKeyConstraint('id', 'transaction_id')
)
op.create_index(op.f('ix_notes_version_end_transaction_id'), 'notes_version', ['end_transaction_id'], unique=False)
op.create_index(op.f('ix_notes_version_operation_type'), 'notes_version', ['operation_type'], unique=False)
op.create_index(op.f('ix_notes_version_transaction_id'), 'notes_version', ['transaction_id'], unique=False)
op.create_table('notes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('content', sa.UnicodeText(), nullable=True),
sa.Column('bibcode', sa.String(length=19), nullable=False),
sa.Column('library_id', biblib.models.GUID(), nullable=True),
sa.Column('date_created', sa.DateTime(), nullable=False),
sa.Column('date_last_modified', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['library_id'], ['library.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('notes')
op.drop_index(op.f('ix_notes_version_transaction_id'), table_name='notes_version')
op.drop_index(op.f('ix_notes_version_operation_type'), table_name='notes_version')
op.drop_index(op.f('ix_notes_version_end_transaction_id'), table_name='notes_version')
op.drop_table('notes_version')
# ### end Alembic commands ###