This commit is contained in:
2026-11-01 17:17:58 +01:00
parent dc9d5a750e
commit 7675acd81e
11 changed files with 528 additions and 18 deletions
@@ -0,0 +1,53 @@
"""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")
@@ -0,0 +1,35 @@
"""add note title
Revision ID: c9e5a1b7d3f2
Revises: b7d4f1a2c3e5
Create Date: 2026-11-01 17:45:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "c9e5a1b7d3f2"
down_revision: Union[str, Sequence[str], None] = "b7d4f1a2c3e5"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.add_column(
"note",
sa.Column(
"title",
sa.String(length=200),
nullable=False,
server_default="Untitled",
),
)
def downgrade() -> None:
with op.batch_alter_table("note") as batch_op:
batch_op.drop_column("title")