fix(migration)
This commit is contained in:
54
backend/migrations/versions/0001_initial_schema.py
Normal file
54
backend/migrations/versions/0001_initial_schema.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
"""Initial schema
|
||||||
|
|
||||||
|
Revision ID: 0001_initial
|
||||||
|
Revises:
|
||||||
|
Create Date: 2026-01-25 19:00:00.000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy import inspect
|
||||||
|
from config.database import Base
|
||||||
|
|
||||||
|
# Import all models to ensure they're registered with Base.metadata
|
||||||
|
from models import (
|
||||||
|
User,
|
||||||
|
Event,
|
||||||
|
EventParticipation,
|
||||||
|
Album,
|
||||||
|
Media,
|
||||||
|
MediaLike,
|
||||||
|
Post,
|
||||||
|
PostMention,
|
||||||
|
PostLike,
|
||||||
|
PostComment,
|
||||||
|
Vlog,
|
||||||
|
VlogLike,
|
||||||
|
VlogComment,
|
||||||
|
Notification,
|
||||||
|
SystemSettings,
|
||||||
|
Information,
|
||||||
|
Ticket
|
||||||
|
)
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '0001_initial'
|
||||||
|
down_revision: Union[str, None] = None
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# Create all tables using Base.metadata with the Alembic connection
|
||||||
|
# This uses the connection from the Alembic context
|
||||||
|
bind = op.get_bind()
|
||||||
|
Base.metadata.create_all(bind=bind)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# Drop all tables
|
||||||
|
bind = op.get_bind()
|
||||||
|
Base.metadata.drop_all(bind=bind)
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ import sqlalchemy as sa
|
|||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = '89527c8da8e1'
|
revision: str = '89527c8da8e1'
|
||||||
down_revision: Union[str, None] = None
|
down_revision: Union[str, None] = '0001_initial'
|
||||||
branch_labels: Union[str, Sequence[str], None] = None
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
depends_on: Union[str, Sequence[str], None] = None
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user