mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-18 20:09:25 +00:00
feat: add migration alembic script
This commit is contained in:
parent
75500bacd2
commit
5f302106a9
1 changed files with 48 additions and 0 deletions
|
|
@ -0,0 +1,48 @@
|
|||
"""Multi-contributors
|
||||
|
||||
Revision ID: 4a88b680263c
|
||||
Revises: 87a621284ae4
|
||||
Create Date: 2025-03-20 11:05:24.951129
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa # noqa: F401
|
||||
import sqlmodel # noqa: F401
|
||||
from alembic_postgresql_enum import TableReference
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '4a88b680263c'
|
||||
down_revision: Union[str, None] = '87a621284ae4'
|
||||
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.add_column('course', sa.Column('open_to_contributors', sa.Boolean(), nullable=False, default=False, server_default='false'))
|
||||
op.add_column('resourceauthor', sa.Column('authorship_status', postgresql.ENUM('ACTIVE', 'PENDING', 'INACTIVE', name='resourceauthorshipstatusenum', create_type=False), nullable=False, default='INACTIVE', server_default='INACTIVE'))
|
||||
op.sync_enum_values(
|
||||
enum_schema='public',
|
||||
enum_name='resourceauthorshipenum',
|
||||
new_values=['CREATOR', 'CONTRIBUTOR', 'MAINTAINER', 'REPORTER'],
|
||||
affected_columns=[TableReference(table_schema='public', table_name='resourceauthor', column_name='authorship')],
|
||||
enum_values_to_rename=[],
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.sync_enum_values(
|
||||
enum_schema='public',
|
||||
enum_name='resourceauthorshipenum',
|
||||
new_values=['CREATOR', 'MAINTAINER', 'REPORTER'],
|
||||
affected_columns=[TableReference(table_schema='public', table_name='resourceauthor', column_name='authorship')],
|
||||
enum_values_to_rename=[],
|
||||
)
|
||||
op.drop_column('resourceauthor', 'authorship_status')
|
||||
op.drop_column('course', 'open_to_contributors')
|
||||
# ### end Alembic commands ###
|
||||
Loading…
Add table
Add a link
Reference in a new issue