Skip to content

Added schema data_manager #234

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

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions alembic/versions/3d0f69f9c513_added_schema_data_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Added schema data_manager

Revision ID: 3d0f69f9c513
Revises: 706d5611a73e
Create Date: 2024-07-09 08:14:48.808354

"""

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

# revision identifiers, used by Alembic.
revision = "3d0f69f9c513"
down_revision = "706d5611a73e"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("create schema data_manager")
op.create_table(
"organization_questions",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("organization_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("type", sa.String(), nullable=True),
sa.Column("config", sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(
["organization_id"], ["organization.id"], ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id"),
schema="data_manager",
)
op.create_index(
op.f("ix_data_manager_organization_questions_organization_id"),
"organization_questions",
["organization_id"],
unique=False,
schema="data_manager",
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(
op.f("ix_data_manager_organization_questions_organization_id"),
table_name="organization_questions",
schema="data_manager",
)
op.drop_table("organization_questions", schema="data_manager")
op.execute("drop schema data_manager")
# ### end Alembic commands ###
105 changes: 105 additions & 0 deletions alembic/versions/5061ecdd2c96_adding_business_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
"""adding business model

Revision ID: 5061ecdd2c96
Revises: 3d0f69f9c513
Create Date: 2024-07-09 12:35:34.766587

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

# revision identifiers, used by Alembic.
revision = '5061ecdd2c96'
down_revision = '3d0f69f9c513'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('business_models',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('organization_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('name', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('llm_config', sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(['organization_id'], ['organization.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='data_manager'
)
op.create_index(op.f('ix_data_manager_business_models_organization_id'), 'business_models', ['organization_id'], unique=False, schema='data_manager')
op.create_table('business_model_questions',
sa.Column('business_model_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('question_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.ForeignKeyConstraint(['business_model_id'], ['data_manager.business_models.id'], ),
sa.ForeignKeyConstraint(['question_id'], ['data_manager.organization_questions.id'], ),
sa.PrimaryKeyConstraint('business_model_id', 'question_id'),
schema='data_manager'
)
op.create_index(op.f('ix_data_manager_business_model_questions_business_model_id'), 'business_model_questions', ['business_model_id'], unique=False, schema='data_manager')
op.create_index(op.f('ix_data_manager_business_model_questions_question_id'), 'business_model_questions', ['question_id'], unique=False, schema='data_manager')
op.create_table('data_concepts',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('business_model_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('question_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.Column('input', sa.String(), nullable=True),
sa.ForeignKeyConstraint(['business_model_id'], ['data_manager.business_models.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['question_id'], ['data_manager.organization_questions.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='data_manager'
)
op.create_index(op.f('ix_data_manager_data_concepts_business_model_id'), 'data_concepts', ['business_model_id'], unique=False, schema='data_manager')
op.create_index(op.f('ix_data_manager_data_concepts_created_by'), 'data_concepts', ['created_by'], unique=False, schema='data_manager')
op.create_index(op.f('ix_data_manager_data_concepts_question_id'), 'data_concepts', ['question_id'], unique=False, schema='data_manager')
op.create_table('resource',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('original_name', sa.String(), nullable=True),
sa.Column('aliases', sa.ARRAY(sa.String()), nullable=True),
sa.Column('type', sa.String(), nullable=True),
sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
schema='data_manager'
)
op.create_index(op.f('ix_data_manager_resource_created_by'), 'resource', ['created_by'], unique=False, schema='data_manager')
op.create_table('rules',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('data_concept_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('type', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('autogenerated', sa.Boolean(), nullable=True),
sa.Column('config', sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['data_concept_id'], ['data_manager.data_concepts.id'], ),
sa.PrimaryKeyConstraint('id'),
schema='data_manager'
)
op.create_index(op.f('ix_data_manager_rules_created_by'), 'rules', ['created_by'], unique=False, schema='data_manager')
op.create_index(op.f('ix_data_manager_rules_data_concept_id'), 'rules', ['data_concept_id'], unique=False, schema='data_manager')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_data_manager_rules_data_concept_id'), table_name='rules', schema='data_manager')
op.drop_index(op.f('ix_data_manager_rules_created_by'), table_name='rules', schema='data_manager')
op.drop_table('rules', schema='data_manager')
op.drop_index(op.f('ix_data_manager_resource_created_by'), table_name='resource', schema='data_manager')
op.drop_table('resource', schema='data_manager')
op.drop_index(op.f('ix_data_manager_data_concepts_question_id'), table_name='data_concepts', schema='data_manager')
op.drop_index(op.f('ix_data_manager_data_concepts_created_by'), table_name='data_concepts', schema='data_manager')
op.drop_index(op.f('ix_data_manager_data_concepts_business_model_id'), table_name='data_concepts', schema='data_manager')
op.drop_table('data_concepts', schema='data_manager')
op.drop_index(op.f('ix_data_manager_business_model_questions_question_id'), table_name='business_model_questions', schema='data_manager')
op.drop_index(op.f('ix_data_manager_business_model_questions_business_model_id'), table_name='business_model_questions', schema='data_manager')
op.drop_table('business_model_questions', schema='data_manager')
op.drop_index(op.f('ix_data_manager_business_models_organization_id'), table_name='business_models', schema='data_manager')
op.drop_table('business_models', schema='data_manager')
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion submodules/model