-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path9a8abc15a493_adds_data_blocks.py
More file actions
99 lines (91 loc) · 3.73 KB
/
9a8abc15a493_adds_data_blocks.py
File metadata and controls
99 lines (91 loc) · 3.73 KB
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
"""adds data blocks
Revision ID: 9a8abc15a493
Revises: 4ffb627479d3
Create Date: 2026-01-20 23:08:30.530156
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "9a8abc15a493"
down_revision = "4ffb627479d3"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"data_block",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("organization_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("project_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.Column("type", sa.String(), nullable=True),
sa.Column("sql_config", sa.JSON(), nullable=True),
sa.Column("sql_data", sa.ARRAY(sa.JSON()), nullable=True),
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(
["organization_id"], ["organization.id"], ondelete="CASCADE"
),
sa.ForeignKeyConstraint(["project_id"], ["project.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_data_block_created_by"), "data_block", ["created_by"], unique=False
)
op.create_index(
op.f("ix_data_block_organization_id"),
"data_block",
["organization_id"],
unique=False,
)
op.create_index(
op.f("ix_data_block_project_id"), "data_block", ["project_id"], unique=False
)
op.create_table(
"data_block_attributes",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("data_block_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("name", sa.String(), nullable=True),
sa.Column("data_type", sa.String(), nullable=True),
sa.Column("is_primary_key", sa.Boolean(), nullable=True),
sa.Column("relative_position", sa.Integer(), nullable=True),
sa.Column("user_created", sa.Boolean(), nullable=True),
sa.Column("source_code", sa.String(), nullable=True),
sa.Column("state", sa.String(), nullable=True),
sa.Column("logs", sa.ARRAY(sa.String()), nullable=True),
sa.Column("started_at", sa.DateTime(), nullable=True),
sa.Column("finished_at", sa.DateTime(), nullable=True),
sa.Column("progress", sa.Float(), nullable=True),
sa.Column(
"additional_config",
sa.JSON(),
nullable=True,
comment="used when data_type == LLM_RESPONSE",
),
sa.ForeignKeyConstraint(
["data_block_id"], ["data_block.id"], ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_data_block_attributes_data_block_id"),
"data_block_attributes",
["data_block_id"],
unique=False,
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(
op.f("ix_data_block_attributes_data_block_id"),
table_name="data_block_attributes",
)
op.drop_table("data_block_attributes")
op.drop_index(op.f("ix_data_block_project_id"), table_name="data_block")
op.drop_index(op.f("ix_data_block_organization_id"), table_name="data_block")
op.drop_index(op.f("ix_data_block_created_by"), table_name="data_block")
op.drop_table("data_block")
# ### end Alembic commands ###