Skip to content

Commit 8bfaa2a

Browse files
committed
Add db migration script for functions_api
1 parent 810a1fa commit 8bfaa2a

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
"""Add function api tables
2+
3+
Revision ID: 44f40f1069aa
4+
Revises: 0d52976dc616
5+
Create Date: 2025-05-09 13:12:31.423832+00:00
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
from sqlalchemy.dialects import postgresql
12+
13+
# revision identifiers, used by Alembic.
14+
revision = "44f40f1069aa"
15+
down_revision = "0d52976dc616"
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.create_table(
23+
"funcapi_function_job_collections",
24+
sa.Column("uuid", postgresql.UUID(as_uuid=True), nullable=False),
25+
sa.Column("title", sa.String(), nullable=True),
26+
sa.Column("description", sa.String(), nullable=True),
27+
sa.PrimaryKeyConstraint("uuid", name="funcapi_function_job_collections_pk"),
28+
)
29+
op.create_index(
30+
op.f("ix_funcapi_function_job_collections_uuid"),
31+
"funcapi_function_job_collections",
32+
["uuid"],
33+
unique=False,
34+
)
35+
op.create_table(
36+
"funcapi_functions",
37+
sa.Column("uuid", postgresql.UUID(as_uuid=True), nullable=False),
38+
sa.Column("title", sa.String(), nullable=True),
39+
sa.Column("function_class", sa.String(), nullable=True),
40+
sa.Column("description", sa.String(), nullable=True),
41+
sa.Column("input_schema", sa.JSON(), nullable=True),
42+
sa.Column("output_schema", sa.JSON(), nullable=True),
43+
sa.Column("system_tags", sa.JSON(), nullable=True),
44+
sa.Column("user_tags", sa.JSON(), nullable=True),
45+
sa.Column("class_specific_data", sa.JSON(), nullable=True),
46+
sa.Column("default_inputs", sa.JSON(), nullable=True),
47+
sa.PrimaryKeyConstraint("uuid", name="funcapi_functions_pk"),
48+
)
49+
op.create_index(
50+
op.f("ix_funcapi_functions_uuid"), "funcapi_functions", ["uuid"], unique=False
51+
)
52+
op.create_table(
53+
"funcapi_function_jobs",
54+
sa.Column("uuid", postgresql.UUID(as_uuid=True), nullable=False),
55+
sa.Column("title", sa.String(), nullable=True),
56+
sa.Column("function_uuid", postgresql.UUID(as_uuid=True), nullable=False),
57+
sa.Column("function_class", sa.String(), nullable=True),
58+
sa.Column("status", sa.String(), nullable=True),
59+
sa.Column("inputs", sa.JSON(), nullable=True),
60+
sa.Column("outputs", sa.JSON(), nullable=True),
61+
sa.Column("class_specific_data", sa.JSON(), nullable=True),
62+
sa.ForeignKeyConstraint(
63+
["function_uuid"],
64+
["funcapi_functions.uuid"],
65+
name="fk_function_jobs_to_function_uuid",
66+
onupdate="CASCADE",
67+
ondelete="CASCADE",
68+
),
69+
sa.PrimaryKeyConstraint("uuid", name="funcapi_function_jobs_pk"),
70+
)
71+
op.create_index(
72+
op.f("ix_funcapi_function_jobs_function_uuid"),
73+
"funcapi_function_jobs",
74+
["function_uuid"],
75+
unique=False,
76+
)
77+
op.create_index(
78+
op.f("ix_funcapi_function_jobs_uuid"),
79+
"funcapi_function_jobs",
80+
["uuid"],
81+
unique=False,
82+
)
83+
op.create_table(
84+
"funcapi_function_job_collections_to_function_jobs",
85+
sa.Column(
86+
"function_job_collection_uuid", postgresql.UUID(as_uuid=True), nullable=True
87+
),
88+
sa.Column("function_job_uuid", postgresql.UUID(as_uuid=True), nullable=True),
89+
sa.ForeignKeyConstraint(
90+
["function_job_collection_uuid"],
91+
["funcapi_function_job_collections.uuid"],
92+
name="fk_func_job_coll_to_func_jobs_to_func_job_coll_uuid",
93+
onupdate="CASCADE",
94+
ondelete="CASCADE",
95+
),
96+
sa.ForeignKeyConstraint(
97+
["function_job_uuid"],
98+
["funcapi_function_jobs.uuid"],
99+
name="fk_func_job_coll_to_func_jobs_to_func_job_uuid",
100+
onupdate="CASCADE",
101+
ondelete="CASCADE",
102+
),
103+
)
104+
# ### end Alembic commands ###
105+
106+
107+
def downgrade():
108+
# ### commands auto generated by Alembic - please adjust! ###
109+
op.drop_table("funcapi_function_job_collections_to_function_jobs")
110+
op.drop_index(
111+
op.f("ix_funcapi_function_jobs_uuid"), table_name="funcapi_function_jobs"
112+
)
113+
op.drop_index(
114+
op.f("ix_funcapi_function_jobs_function_uuid"),
115+
table_name="funcapi_function_jobs",
116+
)
117+
op.drop_table("funcapi_function_jobs")
118+
op.drop_index(op.f("ix_funcapi_functions_uuid"), table_name="funcapi_functions")
119+
op.drop_table("funcapi_functions")
120+
op.drop_index(
121+
op.f("ix_funcapi_function_job_collections_uuid"),
122+
table_name="funcapi_function_job_collections",
123+
)
124+
op.drop_table("funcapi_function_job_collections")
125+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)