Add migration for Color
This commit is contained in:
parent
419014404f
commit
51daf73c0c
33
alembic/versions/20250326_165731_52d7ba73_create_color.py
Normal file
33
alembic/versions/20250326_165731_52d7ba73_create_color.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
"""create colors table
|
||||||
|
|
||||||
|
Revision ID: b7c8d9e0f1g2
|
||||||
|
Revises:
|
||||||
|
Create Date: 2023-12-20 10:00:00.000000
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
# revision identifiers
|
||||||
|
revision = 'b7c8d9e0f1g2'
|
||||||
|
down_revision = None
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table(
|
||||||
|
'colors',
|
||||||
|
sa.Column('id', sa.String(), primary_key=True, default=lambda: str(uuid.uuid4())),
|
||||||
|
sa.Column('name', sa.String(), nullable=False, index=True),
|
||||||
|
sa.Column('hex_code', sa.String(7)),
|
||||||
|
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_index('ix_colors_name', 'colors', ['name'])
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_index('ix_colors_name', 'colors')
|
||||||
|
op.drop_table('colors')
|
Loading…
x
Reference in New Issue
Block a user