"""Initial migration with all models Revision ID: ce4a7e381942 Revises: Create Date: 2025-04-29 13:27:08.356393 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = 'ce4a7e381942' down_revision = None branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('legislation', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(), nullable=False), sa.Column('full_text', sa.Text(), nullable=True), sa.Column('jurisdiction', sa.String(), nullable=True), sa.Column('type', sa.String(), nullable=True), sa.Column('status', sa.String(), nullable=True), sa.Column('effective_date', sa.Date(), nullable=True), sa.Column('enactment_date', sa.Date(), nullable=True), sa.Column('source_url', sa.String(), nullable=True), sa.Column('last_updated', sa.DateTime(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_table('monitoring_sources', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=False), sa.Column('url', sa.String(), nullable=False), sa.Column('type', sa.String(), nullable=False), sa.Column('frequency_minutes', sa.Integer(), nullable=True), sa.Column('last_checked', sa.DateTime(), nullable=True), sa.Column('is_active', sa.Boolean(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('url') ) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=80), nullable=False), sa.Column('password_hash', sa.String(length=128), nullable=False), sa.Column('full_name', sa.String(length=120), nullable=True), sa.Column('role', sa.String(length=80), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('username') ) op.create_table('amendments', sa.Column('id', sa.Integer(), nullable=False), sa.Column('legislation_id', sa.Integer(), nullable=False), sa.Column('proposed_changes', sa.Text(), nullable=False), sa.Column('rationale', sa.Text(), nullable=True), sa.Column('status', sa.String(), nullable=True), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('last_updated', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), sa.ForeignKeyConstraint(['legislation_id'], ['legislation.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('cross_references', sa.Column('id', sa.Integer(), nullable=False), sa.Column('source_legislation_id', sa.Integer(), nullable=False), sa.Column('target_legislation_id', sa.Integer(), nullable=False), sa.Column('relationship_type', sa.String(), nullable=False), sa.Column('details', sa.Text(), nullable=True), sa.Column('identified_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['source_legislation_id'], ['legislation.id'], ), sa.ForeignKeyConstraint(['target_legislation_id'], ['legislation.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('source_legislation_id', 'target_legislation_id', 'relationship_type', name='_source_target_rel_uc') ) op.create_table('drafts', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(), nullable=False), sa.Column('content', sa.Text(), nullable=True), sa.Column('policy_intent', sa.Text(), nullable=True), sa.Column('status', sa.String(), nullable=True), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('related_legislation_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('last_updated', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), sa.ForeignKeyConstraint(['related_legislation_id'], ['legislation.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('impact_analyses', sa.Column('id', sa.Integer(), nullable=False), sa.Column('document_id', sa.Integer(), nullable=False), sa.Column('document_type', sa.String(), nullable=False), sa.Column('analysis_type', sa.String(), nullable=False), sa.Column('predicted_impact', sa.Text(), nullable=True), sa.Column('confidence_score', sa.Float(), nullable=True), sa.Column('rationale', sa.Text(), nullable=True), sa.Column('generated_by_user_id', sa.Integer(), nullable=True), sa.Column('generated_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['generated_by_user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('monitored_events', sa.Column('id', sa.Integer(), nullable=False), sa.Column('source_id', sa.Integer(), nullable=False), sa.Column('detected_at', sa.DateTime(), nullable=True), sa.Column('event_summary', sa.Text(), nullable=False), sa.Column('event_details', sa.Text(), nullable=True), sa.Column('relevance_score', sa.Float(), nullable=True), sa.Column('related_legislation_id', sa.Integer(), nullable=True), sa.Column('status', sa.String(), nullable=True), sa.ForeignKeyConstraint(['related_legislation_id'], ['legislation.id'], ), sa.ForeignKeyConstraint(['source_id'], ['monitoring_sources.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('recommendations', sa.Column('id', sa.Integer(), nullable=False), sa.Column('related_legislation_id', sa.Integer(), nullable=True), sa.Column('recommendation_type', sa.String(), nullable=False), sa.Column('recommendation_text', sa.Text(), nullable=False), sa.Column('rationale', sa.Text(), nullable=True), sa.Column('source_event_id', sa.Integer(), nullable=True), sa.Column('status', sa.String(), nullable=True), sa.Column('generated_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['related_legislation_id'], ['legislation.id'], ), sa.ForeignKeyConstraint(['source_event_id'], ['monitored_events.id'], ), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('recommendations') op.drop_table('monitored_events') op.drop_table('impact_analyses') op.drop_table('drafts') op.drop_table('cross_references') op.drop_table('amendments') op.drop_table('users') op.drop_table('monitoring_sources') op.drop_table('legislation') # ### end Alembic commands ###