Files
2026-11-01 17:17:58 +01:00

54 lines
1.7 KiB
Python

"""create notes
Revision ID: b7d4f1a2c3e5
Revises: 1a7c3e5d9b21
Create Date: 2026-11-01 17:30:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "b7d4f1a2c3e5"
down_revision: Union[str, Sequence[str], None] = "1a7c3e5d9b21"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"note",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Integer(), nullable=False),
sa.Column("content", sa.Text(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=False),
sa.Column("updated_at", sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(["user_id"], ["user.id"]),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f("ix_note_user_id"), "note", ["user_id"], unique=False)
op.create_table(
"note_item",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("note_id", sa.Integer(), nullable=False),
sa.Column("text", sa.String(length=255), nullable=False),
sa.Column("is_done", sa.Boolean(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(["note_id"], ["note.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_note_item_note_id"), "note_item", ["note_id"], unique=False
)
def downgrade() -> None:
op.drop_index(op.f("ix_note_item_note_id"), table_name="note_item")
op.drop_table("note_item")
op.drop_index(op.f("ix_note_user_id"), table_name="note")
op.drop_table("note")