Initial commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""add_table_of_contents_field
|
||||
|
||||
Revision ID: 350115ea15b8
|
||||
Revises: e5ffbf97468e
|
||||
Create Date: 2025-11-01 17:03:15.297500
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '350115ea15b8'
|
||||
down_revision: Union[str, Sequence[str], None] = 'e5ffbf97468e'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# Add table_of_contents JSON column
|
||||
op.add_column('books', sa.Column('table_of_contents', sa.JSON(), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# Remove table_of_contents column
|
||||
op.drop_column('books', 'table_of_contents')
|
||||
@@ -0,0 +1,79 @@
|
||||
"""Initial schema
|
||||
|
||||
Revision ID: e5ffbf97468e
|
||||
Revises:
|
||||
Create Date: 2025-11-01 11:55:11.896876
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'e5ffbf97468e'
|
||||
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."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('books',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('title', sa.String(length=500), nullable=False),
|
||||
sa.Column('author', sa.String(length=255), nullable=True),
|
||||
sa.Column('original_file_path', sa.String(length=1000), nullable=False),
|
||||
sa.Column('markdown_file_path', sa.String(length=1000), nullable=False),
|
||||
sa.Column('source_type', sa.Enum('PDF', 'MARKDOWN', name='sourcetype'), nullable=False),
|
||||
sa.Column('file_hash', sa.String(length=64), nullable=False),
|
||||
sa.Column('added_date', sa.DateTime(), nullable=False),
|
||||
sa.Column('modified_date', sa.DateTime(), nullable=False),
|
||||
sa.Column('pdf_creation_date', sa.DateTime(), nullable=True),
|
||||
sa.Column('pdf_mod_date', sa.DateTime(), nullable=True),
|
||||
sa.Column('pdf_creator', sa.String(length=255), nullable=True),
|
||||
sa.Column('pdf_producer', sa.String(length=255), nullable=True),
|
||||
sa.Column('page_count', sa.Integer(), nullable=True),
|
||||
sa.Column('word_count', sa.Integer(), nullable=True),
|
||||
sa.Column('chapter_count', sa.Integer(), nullable=True),
|
||||
sa.Column('subject', sa.String(length=500), nullable=True),
|
||||
sa.Column('keywords', sa.Text(), nullable=True),
|
||||
sa.Column('category', sa.String(length=100), nullable=True),
|
||||
sa.Column('tags', sa.JSON(), nullable=True),
|
||||
sa.Column('isbn', sa.String(length=20), nullable=True),
|
||||
sa.Column('publisher', sa.String(length=255), nullable=True),
|
||||
sa.Column('publication_year', sa.Integer(), nullable=True),
|
||||
sa.Column('language', sa.String(length=10), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('file_hash')
|
||||
)
|
||||
op.create_index(op.f('ix_books_author'), 'books', ['author'], unique=False)
|
||||
op.create_index(op.f('ix_books_category'), 'books', ['category'], unique=False)
|
||||
op.create_index(op.f('ix_books_source_type'), 'books', ['source_type'], unique=False)
|
||||
op.create_index(op.f('ix_books_title'), 'books', ['title'], unique=False)
|
||||
op.create_table('book_notes',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('book_id', sa.Integer(), nullable=False),
|
||||
sa.Column('note_type', sa.Enum('SUMMARY', 'REVIEW', 'TAG', 'OTHER', name='notetype'), nullable=False),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column('created_date', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['book_id'], ['books.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_book_type', 'book_notes', ['book_id', 'note_type'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index('idx_book_type', table_name='book_notes')
|
||||
op.drop_table('book_notes')
|
||||
op.drop_index(op.f('ix_books_title'), table_name='books')
|
||||
op.drop_index(op.f('ix_books_source_type'), table_name='books')
|
||||
op.drop_index(op.f('ix_books_category'), table_name='books')
|
||||
op.drop_index(op.f('ix_books_author'), table_name='books')
|
||||
op.drop_table('books')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user