-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from Congress-Dev/master-tagging
Add new schema for prompts
- Loading branch information
Showing
18 changed files
with
473 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
backend/alembic/versions/9a72e5faa767_add_prompts_schema.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,60 @@ | ||
"""Add prompts schema | ||
Revision ID: 9a72e5faa767 | ||
Revises: 1d773a33ec53 | ||
Create Date: 2024-12-18 21:02:06.298753 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
from sqlalchemy.schema import CreateSchema | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '9a72e5faa767' | ||
down_revision: Union[str, None] = '1d773a33ec53' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.execute(CreateSchema("prompts", if_not_exists=True)) | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('prompt', | ||
sa.Column('prompt_id', sa.Integer(), nullable=False), | ||
sa.Column('version', sa.String(), nullable=False), | ||
sa.Column('title', sa.String(), nullable=False), | ||
sa.Column('description', sa.String(), nullable=True), | ||
sa.Column('prompt', sa.String(), nullable=False), | ||
sa.PrimaryKeyConstraint('prompt_id'), | ||
schema='prompts' | ||
) | ||
op.create_table('prompt_batch', | ||
sa.Column('prompt_batch_id', sa.Integer(), nullable=False), | ||
sa.Column('prompt_id', sa.Integer(), nullable=True), | ||
sa.Column('legislation_version_id', sa.Integer(), nullable=True), | ||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), | ||
sa.Column('completed_at', sa.DateTime(), nullable=True), | ||
sa.Column('attempted', sa.Integer(), nullable=False), | ||
sa.Column('successful', sa.Integer(), nullable=False), | ||
sa.Column('failed', sa.Integer(), nullable=False), | ||
sa.Column('skipped', sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint(['legislation_version_id'], ['legislation_version.legislation_version_id'], ondelete='CASCADE'), | ||
sa.ForeignKeyConstraint(['prompt_id'], ['prompts.prompt.prompt_id'], ondelete='CASCADE'), | ||
sa.PrimaryKeyConstraint('prompt_batch_id'), | ||
schema='prompts' | ||
) | ||
op.create_index(op.f('ix_prompts_prompt_batch_legislation_version_id'), 'prompt_batch', ['legislation_version_id'], unique=False, schema='prompts') | ||
op.create_index(op.f('ix_prompts_prompt_batch_prompt_id'), 'prompt_batch', ['prompt_id'], unique=False, schema='prompts') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f('ix_prompts_prompt_batch_prompt_id'), table_name='prompt_batch', schema='prompts') | ||
op.drop_index(op.f('ix_prompts_prompt_batch_legislation_version_id'), table_name='prompt_batch', schema='prompts') | ||
op.drop_table('prompt_batch', schema='prompts') | ||
op.drop_table('prompt', schema='prompts') | ||
# ### end Alembic commands ### |
44 changes: 44 additions & 0 deletions
44
backend/alembic/versions/aee414b2c361_create_prompt_tagging_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,44 @@ | ||
"""Create prompt tagging table | ||
Revision ID: aee414b2c361 | ||
Revises: 9a72e5faa767 | ||
Create Date: 2024-12-18 21:04:37.411800 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'aee414b2c361' | ||
down_revision: Union[str, None] = '9a72e5faa767' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('legislation_content_tag', | ||
sa.Column('legislation_content_tag_id', sa.Integer(), nullable=False), | ||
sa.Column('prompt_batch_id', sa.Integer(), nullable=True), | ||
sa.Column('legislation_content_id', sa.Integer(), nullable=True), | ||
sa.Column('tags', postgresql.ARRAY(sa.String()), nullable=True), | ||
sa.ForeignKeyConstraint(['legislation_content_id'], ['legislation_content.legislation_content_id'], ondelete='CASCADE'), | ||
sa.ForeignKeyConstraint(['prompt_batch_id'], ['prompts.prompt_batch.prompt_batch_id'], ), | ||
sa.PrimaryKeyConstraint('legislation_content_tag_id') | ||
) | ||
op.create_index(op.f('ix_legislation_content_tag_legislation_content_id'), 'legislation_content_tag', ['legislation_content_id'], unique=False) | ||
op.create_index(op.f('ix_legislation_content_tag_prompt_batch_id'), 'legislation_content_tag', ['prompt_batch_id'], unique=False) | ||
op.create_index(op.f('ix_legislation_content_tag_tags'), 'legislation_content_tag', ['tags'], unique=False) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f('ix_legislation_content_tag_tags'), table_name='legislation_content_tag') | ||
op.drop_index(op.f('ix_legislation_content_tag_prompt_batch_id'), table_name='legislation_content_tag') | ||
op.drop_index(op.f('ix_legislation_content_tag_legislation_content_id'), table_name='legislation_content_tag') | ||
op.drop_table('legislation_content_tag') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.