Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cognition apps rework #180

Draft
wants to merge 18 commits into
base: dev
Choose a base branch
from
79 changes: 79 additions & 0 deletions alembic/versions/7daca1f5efc7_adds_synopsis_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"""adds synopsis table

Revision ID: 7daca1f5efc7
Revises: daf80476b9cc
Create Date: 2023-12-30 17:41:33.516169

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '7daca1f5efc7'
down_revision = 'daf80476b9cc'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###

op.create_table('synopsis_spreadsheet',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('dataset_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('synopsis_type', sa.String(), nullable=True),
sa.Column('filter_attribute_name', sa.String(), nullable=True),
sa.Column('task_scope_dict', postgresql.JSON(), nullable=True),
sa.Column('project_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('name', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True),
sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='SET NULL'),
sa.ForeignKeyConstraint(['dataset_id'], ['cognition.markdown_dataset.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['project_id'], ['cognition.project.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='cognition'
)

op.create_index(op.f('ix_cognition_synopsis_spreadsheet_created_by'), 'synopsis_spreadsheet', ['created_by'], unique=False, schema='cognition')
op.create_index(op.f('ix_cognition_synopsis_spreadsheet_dataset_id'), 'synopsis_spreadsheet', ['dataset_id'], unique=False, schema='cognition')
op.create_index(op.f('ix_cognition_synopsis_spreadsheet_project_id'), 'synopsis_spreadsheet', ['project_id'], unique=False, schema='cognition')

op.create_table('synopsis_spreadsheet_row',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('project_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('spreadsheet_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('name', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True),
sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='SET NULL'),
sa.ForeignKeyConstraint(['spreadsheet_id'], ['cognition.synopsis_spreadsheet.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='cognition'
)

op.create_index(op.f('ix_cognition_synopsis_spreadsheet_row_created_by'), 'synopsis_spreadsheet_row', ['created_by'], unique=False, schema='cognition')
op.create_index(op.f('ix_cognition_synopsis_spreadsheet_row_spreadsheet_id'), 'synopsis_spreadsheet_row', ['spreadsheet_id'], unique=False, schema='cognition')

op.add_column('conversation', sa.Column('synopsis_column', sa.String(), nullable=True), schema='cognition')
op.add_column('conversation', sa.Column('synopsis_spreadsheet_row_id', sa.String(), nullable=True), schema='cognition')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('conversation', 'synopsis_column', schema='cognition')
op.drop_column('conversation', 'synopsis_spreadsheet_row_id', schema='cognition')

op.drop_index(op.f('ix_cognition_synopsis_spreadsheet_row_spreadsheet_id'), table_name='synopsis_spreadsheet_row', schema='cognition')
op.drop_index(op.f('ix_cognition_synopsis_spreadsheet_row_created_by'), table_name='synopsis_spreadsheet_row', schema='cognition')

op.drop_table('synopsis_spreadsheet_row', schema='cognition')

op.drop_index(op.f('ix_cognition_synopsis_spreadsheet_project_id'), table_name='synopsis_spreadsheet', schema='cognition')
op.drop_index(op.f('ix_cognition_synopsis_spreadsheet_dataset_id'), table_name='synopsis_spreadsheet', schema='cognition')
op.drop_index(op.f('ix_cognition_synopsis_spreadsheet_created_by'), table_name='synopsis_spreadsheet', schema='cognition')

op.drop_table('synopsis_spreadsheet', schema='cognition')
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""update cognition tables for cognition-apps

Revision ID: 8a340c2ee913
Revises: f6bca8990840
Create Date: 2023-12-24 01:16:44.644352

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '8a340c2ee913'
down_revision = 'f6bca8990840'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###

op.add_column('message', sa.Column('feedback_value', sa.String(), nullable=True), schema='cognition')
op.add_column('message', sa.Column('feedback_category', sa.String(), nullable=True), schema='cognition')
op.add_column('message', sa.Column('selection_widget', sa.ARRAY(sa.JSON()), nullable=True), schema='cognition')

op.add_column('conversation', sa.Column('header', sa.String(), nullable=True), schema='cognition')
op.add_column('conversation', sa.Column('error', sa.String(), nullable=True), schema='cognition')


op.add_column('strategy_step', sa.Column('progress_text', sa.String(), nullable=True), schema='cognition')
op.add_column('strategy_step', sa.Column('enable_emissions', sa.Boolean(), nullable=True), schema='cognition')
op.add_column('strategy_step', sa.Column('execute_if_source_code', sa.String(), nullable=True), schema='cognition')

op.add_column('pipeline_logs', sa.Column('skipped_step', sa.Boolean(), nullable=True), schema='cognition')

op.add_column('project', sa.Column('interface_type', sa.String(), nullable=True), schema='cognition')
op.add_column('project', sa.Column('execute_query_enrichment_if_source_code', sa.String(), nullable=True), schema='cognition')
op.add_column('project', sa.Column('customer_color_primary', sa.String(), nullable=True), schema='cognition')
op.add_column('project', sa.Column('customer_color_primary_only_accent', sa.Boolean(), nullable=True), schema='cognition')
op.add_column('project', sa.Column('customer_color_secondary', sa.String(), nullable=True), schema='cognition')

op.add_column('user', sa.Column('language_display', sa.String(), nullable=True))

op.drop_column('message', 'positive_feedback', schema='cognition')

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###

op.add_column('message', sa.Column('positive_feedback', sa.Boolean(), nullable=True), schema='cognition')

op.drop_column('user', 'language_display')

op.drop_column('project', 'execute_query_enrichment_if_source_code', schema='cognition')
op.drop_column('project', 'interface_type', schema='cognition')
op.drop_column('project', 'customer_color_primary', schema='cognition')
op.drop_column('project', 'customer_color_secondary', schema='cognition')

op.drop_column('pipeline_logs', 'skipped_step', schema='cognition')

op.drop_column('strategy_step', 'execute_if_source_code', schema='cognition')
op.drop_column('strategy_step', 'enable_emissions', schema='cognition')
op.drop_column('strategy_step', 'progress_text', schema='cognition')

op.drop_column('conversation', 'header', schema='cognition')
op.drop_column('conversation', 'error', schema='cognition')

op.drop_column('message', 'feedback_category', schema='cognition')
op.drop_column('message', 'feedback_value', schema='cognition')
op.drop_column('message', 'selection_widget', schema='cognition')

# ### end Alembic commands ###
75 changes: 75 additions & 0 deletions alembic/versions/daf80476b9cc_adds_cognition_teams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""adds cognition teams

Revision ID: daf80476b9cc
Revises: ff7dfeda5c2b
Create Date: 2023-12-28 22:31:25.742383

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'daf80476b9cc'
down_revision = 'ff7dfeda5c2b'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"team",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("organization_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("name", sa.String(), nullable=True),
sa.Column("description", sa.String(), nullable=True),
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(
["organization_id"], ["organization.id"], ondelete="SET NULL"
),
sa.PrimaryKeyConstraint("id"),
schema="cognition",
)

op.create_table(
"team_member",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("team_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(["team_id"], ["cognition.team.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
schema="cognition",
)

op.create_table(
"team_project_access",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("team_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("project_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(["project_id"], ["cognition.project.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(["team_id"], ["cognition.team.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
schema="cognition",
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###

op.drop_table("team_project_access", schema="cognition")

op.drop_table("team_member", schema="cognition")

op.drop_table("team", schema="cognition")
# ### end Alembic commands ###
48 changes: 48 additions & 0 deletions alembic/versions/ff7dfeda5c2b_adds_consumption_logs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""adds consumption logs

Revision ID: ff7dfeda5c2b
Revises: 8a340c2ee913
Create Date: 2023-12-27 12:46:15.429502

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'ff7dfeda5c2b'
down_revision = '8a340c2ee913'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"consumption_log",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("project_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("strategy_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("conversation_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("message_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("complexity", sa.String(), nullable=True),
sa.Column("state", sa.String(), nullable=True),
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(
["project_id"], ["cognition.project.id"], ondelete="SET NULL"
),
sa.ForeignKeyConstraint(
["strategy_id"], ["cognition.strategy.id"], ondelete="SET NULL"
),
sa.PrimaryKeyConstraint("id"),
schema="cognition",
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("consumption_log", schema="cognition")
# ### end Alembic commands ###