File size: 6,804 Bytes
32b4281 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
"""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 ###
|