Initial commit: note-taking/task-tracking app with LLM integration scaffold
Vue 3 + TypeScript frontend with Pinia stores, markdown rendering (marked + DOMPurify), wikilink/tag linkification, and autocomplete. Quart async backend with SQLAlchemy 2.0, PostgreSQL ARRAY columns, task-note companion linking, backlinks, and note-to-task conversion. Docker Compose setup with PostgreSQL 16 and Ollama. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import asyncio
|
||||
from logging.config import fileConfig
|
||||
|
||||
from alembic import context
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
|
||||
from fabledassistant.config import Config
|
||||
from fabledassistant.models import Base
|
||||
|
||||
config = context.config
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
target_metadata = Base.metadata
|
||||
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
context.configure(
|
||||
url=Config.DATABASE_URL,
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def do_run_migrations(connection):
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
async def run_async_migrations() -> None:
|
||||
engine = create_async_engine(Config.DATABASE_URL)
|
||||
async with engine.connect() as connection:
|
||||
await connection.run_sync(do_run_migrations)
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
def run_migrations_online() -> None:
|
||||
asyncio.run(run_async_migrations())
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
@@ -0,0 +1,26 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = ${repr(up_revision)}
|
||||
down_revision: Union[str, None] = ${repr(down_revision)}
|
||||
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
${downgrades if downgrades else "pass"}
|
||||
@@ -0,0 +1,76 @@
|
||||
"""create tasks table
|
||||
|
||||
Revision ID: 0002
|
||||
Revises:
|
||||
Create Date: 2025-01-01 00:00:00.000000
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects.postgresql import ARRAY
|
||||
|
||||
revision = "0002"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
task_status = sa.Enum("todo", "in_progress", "done", name="task_status")
|
||||
task_status.create(op.get_bind(), checkfirst=True)
|
||||
|
||||
task_priority = sa.Enum("none", "low", "medium", "high", name="task_priority")
|
||||
task_priority.create(op.get_bind(), checkfirst=True)
|
||||
|
||||
op.create_table(
|
||||
"tasks",
|
||||
sa.Column("id", sa.Integer(), primary_key=True),
|
||||
sa.Column("title", sa.Text(), nullable=False, server_default=""),
|
||||
sa.Column("description", sa.Text(), nullable=False, server_default=""),
|
||||
sa.Column(
|
||||
"status",
|
||||
task_status,
|
||||
nullable=False,
|
||||
server_default="todo",
|
||||
),
|
||||
sa.Column(
|
||||
"priority",
|
||||
task_priority,
|
||||
nullable=False,
|
||||
server_default="none",
|
||||
),
|
||||
sa.Column("due_date", sa.Date(), nullable=True),
|
||||
sa.Column(
|
||||
"note_id",
|
||||
sa.Integer(),
|
||||
sa.ForeignKey("notes.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
),
|
||||
sa.Column("tags", ARRAY(sa.Text()), nullable=False, server_default="{}"),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
nullable=False,
|
||||
server_default=sa.func.now(),
|
||||
),
|
||||
sa.Column(
|
||||
"updated_at",
|
||||
sa.DateTime(timezone=True),
|
||||
nullable=False,
|
||||
server_default=sa.func.now(),
|
||||
),
|
||||
)
|
||||
|
||||
op.create_index("ix_tasks_tags", "tasks", ["tags"], postgresql_using="gin")
|
||||
op.create_index("ix_tasks_note_id", "tasks", ["note_id"])
|
||||
op.create_index("ix_tasks_status", "tasks", ["status"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index("ix_tasks_status", table_name="tasks")
|
||||
op.drop_index("ix_tasks_note_id", table_name="tasks")
|
||||
op.drop_index("ix_tasks_tags", table_name="tasks")
|
||||
op.drop_table("tasks")
|
||||
|
||||
sa.Enum(name="task_priority").drop(op.get_bind(), checkfirst=True)
|
||||
sa.Enum(name="task_status").drop(op.get_bind(), checkfirst=True)
|
||||
@@ -0,0 +1,48 @@
|
||||
"""create companion notes for existing tasks
|
||||
|
||||
Revision ID: 0003
|
||||
Revises: 0002
|
||||
Create Date: 2025-01-01 00:00:00.000000
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "0003"
|
||||
down_revision = "0002"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
|
||||
# Find tasks that don't have a companion note
|
||||
tasks = conn.execute(
|
||||
sa.text("SELECT id, title, tags FROM tasks WHERE note_id IS NULL")
|
||||
).fetchall()
|
||||
|
||||
for task in tasks:
|
||||
# Create a companion note
|
||||
result = conn.execute(
|
||||
sa.text(
|
||||
"INSERT INTO notes (title, body, tags, created_at, updated_at) "
|
||||
"VALUES (:title, '', :tags, NOW(), NOW()) RETURNING id"
|
||||
),
|
||||
{"title": task.title, "tags": task.tags},
|
||||
)
|
||||
note_id = result.scalar()
|
||||
|
||||
# Link the task to its companion note
|
||||
conn.execute(
|
||||
sa.text("UPDATE tasks SET note_id = :note_id WHERE id = :task_id"),
|
||||
{"note_id": note_id, "task_id": task.id},
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove companion notes that were created by this migration
|
||||
# (notes linked to tasks that were previously unlinked)
|
||||
# This is a best-effort downgrade - we can't perfectly distinguish
|
||||
# migration-created notes from user-created ones
|
||||
pass
|
||||
Reference in New Issue
Block a user