Skip to content

Commit c7bbc16

Browse files
ETL External API (#290)
* perf: add default ETL external API project * fix: use cognition project instead of refinery * perf: add pat etl table * perf(alembic): add personal access token etl * perf(alembic): update personal access token etl * perf(model): update submodules * perf(alembic): personal access token etl tables * style: alembic formatting * fix: table_args * chore: submodules update * chore(alembic): resolve potential merge conflict * chore: update submodules * chore: update submodules * chore: update submodules * perf(alembic): add org_id to pat etl table * chore: update submodules * chore: update submodules * chore: update submodules * chore: update submodules# * chore: update submodules * chore(dev): update submodules
1 parent 97816c8 commit c7bbc16

File tree

2 files changed

+97
-1
lines changed

2 files changed

+97
-1
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
"""adds etl personal access token table
2+
3+
Revision ID: 32f92724c13c
4+
Revises: 10c48793371d
5+
Create Date: 2025-02-21 14:00:36.605984
6+
7+
"""
8+
9+
from alembic import op
10+
import sqlalchemy as sa
11+
from sqlalchemy.dialects import postgresql
12+
13+
# revision identifiers, used by Alembic.
14+
revision = "32f92724c13c"
15+
down_revision = "10c48793371d"
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+
"personal_access_token_etl",
24+
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
25+
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
26+
sa.Column("organization_id", postgresql.UUID(as_uuid=True), nullable=True),
27+
sa.Column("created_at", sa.DateTime(), nullable=True),
28+
sa.Column("name", sa.String(), nullable=True),
29+
sa.Column("expires_at", sa.DateTime(), nullable=True),
30+
sa.Column("last_used", sa.DateTime(), nullable=True),
31+
sa.Column("token", sa.String(), nullable=True),
32+
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
33+
sa.ForeignKeyConstraint(
34+
["organization_id"], ["organization.id"], ondelete="SET NULL"
35+
),
36+
sa.PrimaryKeyConstraint("id"),
37+
schema="cognition",
38+
)
39+
op.create_index(
40+
op.f("ix_cognition_personal_access_token_etl_created_by"),
41+
"personal_access_token_etl",
42+
["created_by"],
43+
unique=False,
44+
schema="cognition",
45+
)
46+
op.create_index(
47+
op.f("ix_cognition_personal_access_token_etl_organization_id"),
48+
"personal_access_token_etl",
49+
["organization_id"],
50+
unique=False,
51+
schema="cognition",
52+
)
53+
op.create_table(
54+
"personal_access_token_scope_etl",
55+
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
56+
sa.Column("created_at", sa.DateTime(), nullable=True),
57+
sa.Column("scope", sa.String(), nullable=True),
58+
sa.Column("subject", sa.String(), nullable=True),
59+
sa.Column("subject_id", postgresql.UUID(as_uuid=True), nullable=True),
60+
sa.Column("token_id", postgresql.UUID(as_uuid=True), nullable=True),
61+
sa.ForeignKeyConstraint(
62+
["token_id"], ["cognition.personal_access_token_etl.id"], ondelete="CASCADE"
63+
),
64+
sa.PrimaryKeyConstraint("id"),
65+
schema="cognition",
66+
)
67+
op.create_index(
68+
op.f("ix_cognition_personal_access_token_scope_etl_token_id"),
69+
"personal_access_token_scope_etl",
70+
["token_id"],
71+
unique=False,
72+
schema="cognition",
73+
)
74+
# ### end Alembic commands ###
75+
76+
77+
def downgrade():
78+
# ### commands auto generated by Alembic - please adjust! ###
79+
op.drop_index(
80+
op.f("ix_cognition_personal_access_token_scope_etl_token_id"),
81+
table_name="personal_access_token_scope_etl",
82+
schema="cognition",
83+
)
84+
op.drop_table("personal_access_token_scope_etl", schema="cognition")
85+
op.drop_index(
86+
op.f("ix_cognition_personal_access_token_etl_organization_id"),
87+
table_name="personal_access_token_etl",
88+
schema="cognition",
89+
)
90+
op.drop_index(
91+
op.f("ix_cognition_personal_access_token_etl_created_by"),
92+
table_name="personal_access_token_etl",
93+
schema="cognition",
94+
)
95+
op.drop_table("personal_access_token_etl", schema="cognition")
96+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)