Compare commits

...

2 Commits

Author SHA1 Message Date
d76d1afd9d create a first alembic revision to generate blocks and pages tables
point alembic.ini at a local sqlite db for testing
2026-03-30 11:32:42 -04:00
7c895c8191 update .gitignore for files under migrations
ignore pycache files, etc.
2026-03-30 11:31:55 -04:00
3 changed files with 54 additions and 1 deletions

5
.gitignore vendored
View File

@@ -16,3 +16,8 @@ target/
# and can be added to the global gitignore or merged into this file. For a more nuclear # and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
# ignorable files in migrations/
**/__pycache__
migrations/env/
migrations/test_db.sqlite

View File

@@ -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]

View File

@@ -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