set up Alembic for handling database migrations #1
@@ -86,7 +86,7 @@ path_separator = os
|
|||||||
# database URL. This is consumed by the user-maintained env.py script only.
|
# database URL. This is consumed by the user-maintained env.py script only.
|
||||||
# other means of configuring database URLs may be customized within the env.py
|
# other means of configuring database URLs may be customized within the env.py
|
||||||
# file.
|
# file.
|
||||||
sqlalchemy.url = driver://user:pass@localhost/dbname
|
sqlalchemy.url = sqlite+pysqlite:///test_db.sqlite
|
||||||
|
|
||||||
|
|
||||||
[post_write_hooks]
|
[post_write_hooks]
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
"""initial outline-rs schema
|
||||||
|
|
||||||
|
Revision ID: 040713502ba4
|
||||||
|
Revises:
|
||||||
|
Create Date: 2026-03-30 10:47:36.255978
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '040713502ba4'
|
||||||
|
down_revision: Union[str, Sequence[str], None] = None
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
|
||||||
|
# block table holds individual bullet points in the outline
|
||||||
|
op.create_table(
|
||||||
|
"blocks",
|
||||||
|
sa.Column("id", sa.INTEGER, primary_key=True),
|
||||||
|
sa.Column("first_child_id", sa.INTEGER, sa.schema.ForeignKey("blocks.id")),
|
||||||
|
sa.Column("next_sibling_id", sa.INTEGER, sa.schema.ForeignKey("blocks.id")),
|
||||||
|
sa.Column("page_id", sa.INTEGER, sa.schema.ForeignKey("pages.id"), index=True),
|
||||||
|
sa.Column("content", sa.types.UnicodeText)
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_table(
|
||||||
|
"pages",
|
||||||
|
sa.Column("id", sa.INTEGER, primary_key=True),
|
||||||
|
sa.Column("root_block_id", sa.INTEGER, sa.schema.ForeignKey("blocks.id")),
|
||||||
|
sa.Column("title", sa.types.UnicodeText)
|
||||||
|
)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
op.drop_table("blocks")
|
||||||
|
op.drop_table("pages")
|
||||||
|
pass
|
||||||
Reference in New Issue
Block a user