"""add papers table

Revision ID: a99e7febbff9
Revises: 851d54415f73
Create Date: 2026-04-01 20:34:24.293154

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'a99e7febbff9'
down_revision = '851d54415f73'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('papers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('doi', sa.String(length=255), nullable=True),
    sa.Column('title', sa.Text(), nullable=True),
    sa.Column('authors', sa.Text(), nullable=True),
    sa.Column('journal', sa.String(length=500), nullable=True),
    sa.Column('year', sa.Integer(), nullable=True),
    sa.Column('abstract', sa.Text(), nullable=True),
    sa.Column('citation_text', sa.Text(), nullable=True),
    sa.Column('bibtex', sa.Text(), nullable=True),
    sa.Column('movebank_study_id', sa.String(length=100), nullable=True),
    sa.Column('dataset_doi', sa.String(length=255), nullable=True),
    sa.Column('species', sa.Text(), nullable=True),
    sa.Column('sensor_types', sa.Text(), nullable=True),
    sa.Column('animal_count', sa.Integer(), nullable=True),
    sa.Column('location_count', sa.Integer(), nullable=True),
    sa.Column('keywords', sa.Text(), nullable=True),
    sa.Column('source', sa.String(length=50), nullable=True),
    sa.Column('source_url', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('papers', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_papers_doi'), ['doi'], unique=True)
        batch_op.create_index(batch_op.f('ix_papers_movebank_study_id'), ['movebank_study_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_papers_year'), ['year'], unique=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('papers', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_papers_year'))
        batch_op.drop_index(batch_op.f('ix_papers_movebank_study_id'))
        batch_op.drop_index(batch_op.f('ix_papers_doi'))

    op.drop_table('papers')
    # ### end Alembic commands ###
