File size: 2,125 Bytes
d57efd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""add updated data

Revision ID: 82908d30ae5a
Revises: fcc0580a4769
Create Date: 2024-10-09 14:12:01.147393

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision: str = '82908d30ae5a'
down_revision: Union[str, None] = 'fcc0580a4769'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('session_publisher',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('metadata_id', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
    sa.ForeignKeyConstraint(['metadata_id'], ['metadata.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_session_publisher_id'), 'session_publisher', ['id'], unique=False)
    op.add_column('metadata', sa.Column('thumbnail', sa.LargeBinary(), nullable=True))
    op.add_column('planning', sa.Column('trials_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'planning', 'trials', ['trials_id'], ['id'])
    op.drop_column('planning', 'token_planned')
    op.drop_column('planning', 'token_used')
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('planning', sa.Column('token_used', mysql.INTEGER(), autoincrement=False, nullable=False))
    op.add_column('planning', sa.Column('token_planned', mysql.INTEGER(), autoincrement=False, nullable=False))
    op.drop_constraint(None, 'planning', type_='foreignkey')
    op.drop_column('planning', 'trials_id')
    op.drop_column('metadata', 'thumbnail')
    op.drop_index(op.f('ix_session_publisher_id'), table_name='session_publisher')
    op.drop_table('session_publisher')
    # ### end Alembic commands ###