All checks were successful
Mobile Android Release / android-release (push) Successful in 1m32s
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""add user notes
|
|
|
|
Revision ID: e4c7b2a9d6f1
|
|
Revises: 9bac7bf02e38
|
|
Create Date: 2026-05-12 17:10:00.000000
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision: str = 'e4c7b2a9d6f1'
|
|
down_revision: Union[str, None] = '9bac7bf02e38'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
conn = op.get_bind()
|
|
conn.execute(sa.text("""
|
|
CREATE TABLE IF NOT EXISTS user_notes (
|
|
id SERIAL PRIMARY KEY,
|
|
user_id INTEGER NOT NULL UNIQUE REFERENCES users(id) ON DELETE CASCADE,
|
|
content TEXT NOT NULL,
|
|
created_at TIMESTAMP NOT NULL,
|
|
updated_at TIMESTAMP NOT NULL
|
|
)
|
|
"""))
|
|
conn.execute(sa.text("CREATE INDEX IF NOT EXISTS ix_user_notes_id ON user_notes (id)"))
|
|
conn.execute(sa.text("CREATE INDEX IF NOT EXISTS ix_user_notes_user_id ON user_notes (user_id)"))
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(op.f('ix_user_notes_user_id'), table_name='user_notes')
|
|
op.drop_index(op.f('ix_user_notes_id'), table_name='user_notes')
|
|
op.drop_table('user_notes')
|