From 4f5feb715133a21a589695036ddd5dfff71166bb Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Tue, 11 Feb 2025 13:33:10 +0100 Subject: [PATCH 01/21] perf: add default ETL external API project --- .../versions/cb4412d2ae2e_etl_api_project.py | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 alembic/versions/cb4412d2ae2e_etl_api_project.py diff --git a/alembic/versions/cb4412d2ae2e_etl_api_project.py b/alembic/versions/cb4412d2ae2e_etl_api_project.py new file mode 100644 index 00000000..9ebda71d --- /dev/null +++ b/alembic/versions/cb4412d2ae2e_etl_api_project.py @@ -0,0 +1,64 @@ +"""etl api project + +Revision ID: cb4412d2ae2e +Revises: eb5ecbee5090 +Create Date: 2025-02-11 12:15:10.134446 + +""" + +from alembic import op +import sqlalchemy as sa + +import uuid +import datetime + + +# revision identifiers, used by Alembic. +revision = "cb4412d2ae2e" +down_revision = "eb5ecbee5090" +branch_labels = None +depends_on = None + + +def upgrade(): + meta = sa.MetaData(op.get_bind()) + meta.reflect(only=("organization", "project")) + + organization = sa.Table("organization", meta) + project = sa.Table("project", meta) + + org_id, project_id = uuid.UUID(int=0), uuid.UUID(int=0) + op.bulk_insert( + organization, + [ + { + "id": str(org_id), + "name": "ETL", + "started_at": datetime.datetime.now(datetime.timezone.utc), + "description": "ETL External API", + "max_rows": 0, + "max_cols": 0, + "max_char_count": 0, + "log_admin_requests": "NO_GET", + "conversation_lifespan_days": 0, + "file_lifespan_days": 0, + } + ], + ) + op.bulk_insert( + project, + [ + { + "id": str(project_id), + "name": "ETL External API", + "description": "ETL External API Default Project", + "organization_id": str(org_id), + } + ], + ) + + +def downgrade(): + org_id, project_id = uuid.UUID(int=0), uuid.UUID(int=0) + op.execute("DELETE FROM \"project\" WHERE id = '{}'".format(str(project_id))) + op.execute("DELETE FROM \"organization\" WHERE id = '{}'".format(str(org_id))) From 3c06159147b0ff124679c4a6e0188a4d7d5f21c6 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Tue, 11 Feb 2025 14:28:41 +0100 Subject: [PATCH 02/21] fix: use cognition project instead of refinery --- alembic/versions/cb4412d2ae2e_etl_api_project.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/alembic/versions/cb4412d2ae2e_etl_api_project.py b/alembic/versions/cb4412d2ae2e_etl_api_project.py index 9ebda71d..cd297b10 100644 --- a/alembic/versions/cb4412d2ae2e_etl_api_project.py +++ b/alembic/versions/cb4412d2ae2e_etl_api_project.py @@ -21,11 +21,14 @@ def upgrade(): - meta = sa.MetaData(op.get_bind()) - meta.reflect(only=("organization", "project")) + refinery_meta = sa.MetaData(op.get_bind()) + cognition_meta = sa.MetaData(op.get_bind(), schema="cognition") - organization = sa.Table("organization", meta) - project = sa.Table("project", meta) + refinery_meta.reflect(only=("organization",)) + cognition_meta.reflect(only=("project",)) + + organization = sa.Table("organization", refinery_meta) + project = sa.Table("project", cognition_meta) org_id, project_id = uuid.UUID(int=0), uuid.UUID(int=0) op.bulk_insert( From 553cb24a032bdd105b59835d3c2bc3e287a25276 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Tue, 11 Feb 2025 14:55:37 +0100 Subject: [PATCH 03/21] perf: add pat etl table --- .../46023692929d_add_pat_etl_table.py | 70 +++++++++++++++++++ .../versions/cb4412d2ae2e_etl_api_project.py | 67 ------------------ submodules/model | 2 +- 3 files changed, 71 insertions(+), 68 deletions(-) create mode 100644 alembic/versions/46023692929d_add_pat_etl_table.py delete mode 100644 alembic/versions/cb4412d2ae2e_etl_api_project.py diff --git a/alembic/versions/46023692929d_add_pat_etl_table.py b/alembic/versions/46023692929d_add_pat_etl_table.py new file mode 100644 index 00000000..065f5ff1 --- /dev/null +++ b/alembic/versions/46023692929d_add_pat_etl_table.py @@ -0,0 +1,70 @@ +"""add pat etl table + +Revision ID: 46023692929d +Revises: eb5ecbee5090 +Create Date: 2025-02-11 13:55:03.170678 + +""" + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = "46023692929d" +down_revision = "eb5ecbee5090" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "personal_access_token_etl", + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("dataset_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("scope", sa.String(), nullable=True), + sa.Column("expires_at", sa.DateTime(), nullable=True), + sa.Column("last_used", sa.DateTime(), nullable=True), + sa.Column("token", sa.String(), nullable=True), + sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"), + sa.ForeignKeyConstraint( + ["dataset_id"], ["cognition.markdown_dataset.id"], ondelete="CASCADE" + ), + sa.PrimaryKeyConstraint("id"), + schema="cognition", + ) + op.create_index( + op.f("ix_cognition_personal_access_token_etl_created_by"), + "personal_access_token_etl", + ["created_by"], + unique=False, + schema="cognition", + ) + op.create_index( + op.f("ix_cognition_personal_access_token_etl_dataset_id"), + "personal_access_token_etl", + ["dataset_id"], + unique=False, + schema="cognition", + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index( + op.f("ix_cognition_personal_access_token_etl_dataset_id"), + table_name="personal_access_token_etl", + schema="cognition", + ) + op.drop_index( + op.f("ix_cognition_personal_access_token_etl_created_by"), + table_name="personal_access_token_etl", + schema="cognition", + ) + op.drop_table("personal_access_token_etl", schema="cognition") + # ### end Alembic commands ### diff --git a/alembic/versions/cb4412d2ae2e_etl_api_project.py b/alembic/versions/cb4412d2ae2e_etl_api_project.py deleted file mode 100644 index cd297b10..00000000 --- a/alembic/versions/cb4412d2ae2e_etl_api_project.py +++ /dev/null @@ -1,67 +0,0 @@ -"""etl api project - -Revision ID: cb4412d2ae2e -Revises: eb5ecbee5090 -Create Date: 2025-02-11 12:15:10.134446 - -""" - -from alembic import op -import sqlalchemy as sa - -import uuid -import datetime - - -# revision identifiers, used by Alembic. -revision = "cb4412d2ae2e" -down_revision = "eb5ecbee5090" -branch_labels = None -depends_on = None - - -def upgrade(): - refinery_meta = sa.MetaData(op.get_bind()) - cognition_meta = sa.MetaData(op.get_bind(), schema="cognition") - - refinery_meta.reflect(only=("organization",)) - cognition_meta.reflect(only=("project",)) - - organization = sa.Table("organization", refinery_meta) - project = sa.Table("project", cognition_meta) - - org_id, project_id = uuid.UUID(int=0), uuid.UUID(int=0) - op.bulk_insert( - organization, - [ - { - "id": str(org_id), - "name": "ETL", - "started_at": datetime.datetime.now(datetime.timezone.utc), - "description": "ETL External API", - "max_rows": 0, - "max_cols": 0, - "max_char_count": 0, - "log_admin_requests": "NO_GET", - "conversation_lifespan_days": 0, - "file_lifespan_days": 0, - } - ], - ) - op.bulk_insert( - project, - [ - { - "id": str(project_id), - "name": "ETL External API", - "description": "ETL External API Default Project", - "organization_id": str(org_id), - } - ], - ) - - -def downgrade(): - org_id, project_id = uuid.UUID(int=0), uuid.UUID(int=0) - op.execute("DELETE FROM \"project\" WHERE id = '{}'".format(str(project_id))) - op.execute("DELETE FROM \"organization\" WHERE id = '{}'".format(str(org_id))) diff --git a/submodules/model b/submodules/model index cf337c2d..0e7dca9e 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit cf337c2d46a302f33ed35419c1d95a60871bbe61 +Subproject commit 0e7dca9ed7216e133a745a372028c6b5032c5e41 From ec1c6456dfc684ffd366229b647c40bd621aadf3 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 13 Feb 2025 19:57:35 +0100 Subject: [PATCH 04/21] perf(alembic): add personal access token etl --- ...22fe02f9_add_personal_access_token_etl.py} | 40 +++++++++++++++---- submodules/model | 2 +- 2 files changed, 34 insertions(+), 8 deletions(-) rename alembic/versions/{46023692929d_add_pat_etl_table.py => 268822fe02f9_add_personal_access_token_etl.py} (63%) diff --git a/alembic/versions/46023692929d_add_pat_etl_table.py b/alembic/versions/268822fe02f9_add_personal_access_token_etl.py similarity index 63% rename from alembic/versions/46023692929d_add_pat_etl_table.py rename to alembic/versions/268822fe02f9_add_personal_access_token_etl.py index 065f5ff1..5a83e3bf 100644 --- a/alembic/versions/46023692929d_add_pat_etl_table.py +++ b/alembic/versions/268822fe02f9_add_personal_access_token_etl.py @@ -1,8 +1,8 @@ -"""add pat etl table +"""add personal access token etl -Revision ID: 46023692929d -Revises: eb5ecbee5090 -Create Date: 2025-02-11 13:55:03.170678 +Revision ID: 268822fe02f9 +Revises: 10c48793371d +Create Date: 2025-02-13 18:56:09.512264 """ @@ -11,8 +11,8 @@ from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = "46023692929d" -down_revision = "eb5ecbee5090" +revision = "268822fe02f9" +down_revision = "10c48793371d" branch_labels = None depends_on = None @@ -26,7 +26,6 @@ def upgrade(): 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("scope", sa.String(), nullable=True), sa.Column("expires_at", sa.DateTime(), nullable=True), sa.Column("last_used", sa.DateTime(), nullable=True), sa.Column("token", sa.String(), nullable=True), @@ -51,11 +50,38 @@ def upgrade(): unique=False, schema="cognition", ) + op.create_table( + "personal_access_token_scope_etl", + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("created_at", sa.DateTime(), nullable=True), + sa.Column("scope", sa.String(), nullable=True), + sa.Column("subject", sa.String(), nullable=True), + sa.Column("subject_id", postgresql.UUID(as_uuid=True), nullable=True), + sa.Column("token_id", postgresql.UUID(as_uuid=True), nullable=True), + sa.ForeignKeyConstraint( + ["token_id"], ["cognition.personal_access_token_etl.id"], ondelete="CASCADE" + ), + sa.PrimaryKeyConstraint("id"), + schema="cognition", + ) + op.create_index( + op.f("ix_cognition_personal_access_token_scope_etl_token_id"), + "personal_access_token_scope_etl", + ["token_id"], + unique=False, + schema="cognition", + ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### + op.drop_index( + op.f("ix_cognition_personal_access_token_scope_etl_token_id"), + table_name="personal_access_token_scope_etl", + schema="cognition", + ) + op.drop_table("personal_access_token_scope_etl", schema="cognition") op.drop_index( op.f("ix_cognition_personal_access_token_etl_dataset_id"), table_name="personal_access_token_etl", diff --git a/submodules/model b/submodules/model index 0f3acf9f..c87b97f7 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 0f3acf9f3110ec1e3bd81cab248ba98891a08477 +Subproject commit c87b97f7ba3c21d605e7bc7774a4b1731693e6db From 73ae8bf5c2c2c5faf36dcd0fb9f3c73903a8f693 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Fri, 14 Feb 2025 11:45:29 +0100 Subject: [PATCH 05/21] perf(alembic): update personal access token etl --- ...5_adds_personal_access_token_etl_tables.py | 54 +++++++++++ ...822fe02f9_add_personal_access_token_etl.py | 96 ------------------- 2 files changed, 54 insertions(+), 96 deletions(-) create mode 100644 alembic/versions/193a8c73ff45_adds_personal_access_token_etl_tables.py delete mode 100644 alembic/versions/268822fe02f9_add_personal_access_token_etl.py diff --git a/alembic/versions/193a8c73ff45_adds_personal_access_token_etl_tables.py b/alembic/versions/193a8c73ff45_adds_personal_access_token_etl_tables.py new file mode 100644 index 00000000..3fd32f63 --- /dev/null +++ b/alembic/versions/193a8c73ff45_adds_personal_access_token_etl_tables.py @@ -0,0 +1,54 @@ +"""adds personal access token etl tables + +Revision ID: 193a8c73ff45 +Revises: 10c48793371d +Create Date: 2025-02-14 10:44:23.043073 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '193a8c73ff45' +down_revision = '10c48793371d' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('personal_access_token_etl', + sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), + 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('expires_at', sa.DateTime(), nullable=True), + sa.Column('last_used', sa.DateTime(), nullable=True), + sa.Column('token', sa.String(), nullable=True), + sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + schema='cognition' + ) + op.create_index(op.f('ix_cognition_personal_access_token_etl_created_by'), 'personal_access_token_etl', ['created_by'], unique=False, schema='cognition') + op.create_table('personal_access_token_scope_etl', + sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('scope', sa.String(), nullable=True), + sa.Column('subject', sa.String(), nullable=True), + sa.Column('token_id', postgresql.UUID(as_uuid=True), nullable=True), + sa.ForeignKeyConstraint(['token_id'], ['cognition.personal_access_token_etl.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id'), + schema='cognition' + ) + op.create_index(op.f('ix_cognition_personal_access_token_scope_etl_token_id'), 'personal_access_token_scope_etl', ['token_id'], unique=False, schema='cognition') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_cognition_personal_access_token_scope_etl_token_id'), table_name='personal_access_token_scope_etl', schema='cognition') + op.drop_table('personal_access_token_scope_etl', schema='cognition') + op.drop_index(op.f('ix_cognition_personal_access_token_etl_created_by'), table_name='personal_access_token_etl', schema='cognition') + op.drop_table('personal_access_token_etl', schema='cognition') + # ### end Alembic commands ### diff --git a/alembic/versions/268822fe02f9_add_personal_access_token_etl.py b/alembic/versions/268822fe02f9_add_personal_access_token_etl.py deleted file mode 100644 index 5a83e3bf..00000000 --- a/alembic/versions/268822fe02f9_add_personal_access_token_etl.py +++ /dev/null @@ -1,96 +0,0 @@ -"""add personal access token etl - -Revision ID: 268822fe02f9 -Revises: 10c48793371d -Create Date: 2025-02-13 18:56:09.512264 - -""" - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = "268822fe02f9" -down_revision = "10c48793371d" -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table( - "personal_access_token_etl", - sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("dataset_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("expires_at", sa.DateTime(), nullable=True), - sa.Column("last_used", sa.DateTime(), nullable=True), - sa.Column("token", sa.String(), nullable=True), - sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint( - ["dataset_id"], ["cognition.markdown_dataset.id"], ondelete="CASCADE" - ), - sa.PrimaryKeyConstraint("id"), - schema="cognition", - ) - op.create_index( - op.f("ix_cognition_personal_access_token_etl_created_by"), - "personal_access_token_etl", - ["created_by"], - unique=False, - schema="cognition", - ) - op.create_index( - op.f("ix_cognition_personal_access_token_etl_dataset_id"), - "personal_access_token_etl", - ["dataset_id"], - unique=False, - schema="cognition", - ) - op.create_table( - "personal_access_token_scope_etl", - sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), - sa.Column("created_at", sa.DateTime(), nullable=True), - sa.Column("scope", sa.String(), nullable=True), - sa.Column("subject", sa.String(), nullable=True), - sa.Column("subject_id", postgresql.UUID(as_uuid=True), nullable=True), - sa.Column("token_id", postgresql.UUID(as_uuid=True), nullable=True), - sa.ForeignKeyConstraint( - ["token_id"], ["cognition.personal_access_token_etl.id"], ondelete="CASCADE" - ), - sa.PrimaryKeyConstraint("id"), - schema="cognition", - ) - op.create_index( - op.f("ix_cognition_personal_access_token_scope_etl_token_id"), - "personal_access_token_scope_etl", - ["token_id"], - unique=False, - schema="cognition", - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index( - op.f("ix_cognition_personal_access_token_scope_etl_token_id"), - table_name="personal_access_token_scope_etl", - schema="cognition", - ) - op.drop_table("personal_access_token_scope_etl", schema="cognition") - op.drop_index( - op.f("ix_cognition_personal_access_token_etl_dataset_id"), - table_name="personal_access_token_etl", - schema="cognition", - ) - op.drop_index( - op.f("ix_cognition_personal_access_token_etl_created_by"), - table_name="personal_access_token_etl", - schema="cognition", - ) - op.drop_table("personal_access_token_etl", schema="cognition") - # ### end Alembic commands ### From 5f9175739155e0ac9b68e3975b048accf7d4fa0f Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Fri, 14 Feb 2025 11:48:24 +0100 Subject: [PATCH 06/21] perf(model): update submodules --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index c87b97f7..dfd33854 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit c87b97f7ba3c21d605e7bc7774a4b1731693e6db +Subproject commit dfd338549d3f7fe4838145ef74b3f229e4451abf From 65bd35a3193dd63189ec58e8b04bbbafc5134a7d Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Mon, 17 Feb 2025 10:10:21 +0100 Subject: [PATCH 07/21] perf(alembic): personal access token etl tables --- ... a960b5652c50_adds_personal_access_token_etl_tables.py} | 7 ++++--- submodules/model | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) rename alembic/versions/{193a8c73ff45_adds_personal_access_token_etl_tables.py => a960b5652c50_adds_personal_access_token_etl_tables.py} (93%) diff --git a/alembic/versions/193a8c73ff45_adds_personal_access_token_etl_tables.py b/alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py similarity index 93% rename from alembic/versions/193a8c73ff45_adds_personal_access_token_etl_tables.py rename to alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py index 3fd32f63..620a8c7a 100644 --- a/alembic/versions/193a8c73ff45_adds_personal_access_token_etl_tables.py +++ b/alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py @@ -1,8 +1,8 @@ """adds personal access token etl tables -Revision ID: 193a8c73ff45 +Revision ID: a960b5652c50 Revises: 10c48793371d -Create Date: 2025-02-14 10:44:23.043073 +Create Date: 2025-02-17 09:09:57.859717 """ from alembic import op @@ -10,7 +10,7 @@ from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = '193a8c73ff45' +revision = 'a960b5652c50' down_revision = '10c48793371d' branch_labels = None depends_on = None @@ -36,6 +36,7 @@ def upgrade(): sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('scope', sa.String(), nullable=True), sa.Column('subject', sa.String(), nullable=True), + sa.Column('subject_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('token_id', postgresql.UUID(as_uuid=True), nullable=True), sa.ForeignKeyConstraint(['token_id'], ['cognition.personal_access_token_etl.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), diff --git a/submodules/model b/submodules/model index dfd33854..80ff1a43 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit dfd338549d3f7fe4838145ef74b3f229e4451abf +Subproject commit 80ff1a430d8374bb17d164f94cabe5ca9d76d14f From 1ddb5e5876409444913fdd9faddb33904c7eaf8e Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Mon, 17 Feb 2025 10:10:54 +0100 Subject: [PATCH 08/21] style: alembic formatting --- ...0_adds_personal_access_token_etl_tables.py | 83 ++++++++++++------- 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py b/alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py index 620a8c7a..e3ac4361 100644 --- a/alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py +++ b/alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py @@ -5,51 +5,76 @@ Create Date: 2025-02-17 09:09:57.859717 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = 'a960b5652c50' -down_revision = '10c48793371d' +revision = "a960b5652c50" +down_revision = "10c48793371d" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.create_table('personal_access_token_etl', - sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - 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('expires_at', sa.DateTime(), nullable=True), - sa.Column('last_used', sa.DateTime(), nullable=True), - sa.Column('token', sa.String(), nullable=True), - sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='SET NULL'), - sa.PrimaryKeyConstraint('id'), - schema='cognition' + op.create_table( + "personal_access_token_etl", + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), + 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("expires_at", sa.DateTime(), nullable=True), + sa.Column("last_used", sa.DateTime(), nullable=True), + sa.Column("token", sa.String(), nullable=True), + sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"), + sa.PrimaryKeyConstraint("id"), + schema="cognition", + ) + op.create_index( + op.f("ix_cognition_personal_access_token_etl_created_by"), + "personal_access_token_etl", + ["created_by"], + unique=False, + schema="cognition", + ) + op.create_table( + "personal_access_token_scope_etl", + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), + sa.Column("created_at", sa.DateTime(), nullable=True), + sa.Column("scope", sa.String(), nullable=True), + sa.Column("subject", sa.String(), nullable=True), + sa.Column("subject_id", postgresql.UUID(as_uuid=True), nullable=True), + sa.Column("token_id", postgresql.UUID(as_uuid=True), nullable=True), + sa.ForeignKeyConstraint( + ["token_id"], ["cognition.personal_access_token_etl.id"], ondelete="CASCADE" + ), + sa.PrimaryKeyConstraint("id"), + schema="cognition", ) - op.create_index(op.f('ix_cognition_personal_access_token_etl_created_by'), 'personal_access_token_etl', ['created_by'], unique=False, schema='cognition') - op.create_table('personal_access_token_scope_etl', - sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('scope', sa.String(), nullable=True), - sa.Column('subject', sa.String(), nullable=True), - sa.Column('subject_id', postgresql.UUID(as_uuid=True), nullable=True), - sa.Column('token_id', postgresql.UUID(as_uuid=True), nullable=True), - sa.ForeignKeyConstraint(['token_id'], ['cognition.personal_access_token_etl.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id'), - schema='cognition' + op.create_index( + op.f("ix_cognition_personal_access_token_scope_etl_token_id"), + "personal_access_token_scope_etl", + ["token_id"], + unique=False, + schema="cognition", ) - op.create_index(op.f('ix_cognition_personal_access_token_scope_etl_token_id'), 'personal_access_token_scope_etl', ['token_id'], unique=False, schema='cognition') # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_cognition_personal_access_token_scope_etl_token_id'), table_name='personal_access_token_scope_etl', schema='cognition') - op.drop_table('personal_access_token_scope_etl', schema='cognition') - op.drop_index(op.f('ix_cognition_personal_access_token_etl_created_by'), table_name='personal_access_token_etl', schema='cognition') - op.drop_table('personal_access_token_etl', schema='cognition') + op.drop_index( + op.f("ix_cognition_personal_access_token_scope_etl_token_id"), + table_name="personal_access_token_scope_etl", + schema="cognition", + ) + op.drop_table("personal_access_token_scope_etl", schema="cognition") + op.drop_index( + op.f("ix_cognition_personal_access_token_etl_created_by"), + table_name="personal_access_token_etl", + schema="cognition", + ) + op.drop_table("personal_access_token_etl", schema="cognition") # ### end Alembic commands ### From d359a2b90ec5bb21f0bd968ece3220e290033026 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Mon, 17 Feb 2025 13:21:10 +0100 Subject: [PATCH 09/21] fix: table_args --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index 80ff1a43..1b510126 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 80ff1a430d8374bb17d164f94cabe5ca9d76d14f +Subproject commit 1b510126dcebc9d58f1e7983bb260c306c626255 From 485adb35bfbfa3c0940f99a12f9b685e200b9b52 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 20 Feb 2025 11:26:22 +0100 Subject: [PATCH 10/21] chore: submodules update --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index 1b510126..8ddbae72 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 1b510126dcebc9d58f1e7983bb260c306c626255 +Subproject commit 8ddbae72b0cb27d816ee06ba39a63479e698cee1 From b46a1cc3c40742026150a4c7fed6617c56c3d4a3 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 20 Feb 2025 11:32:02 +0100 Subject: [PATCH 11/21] chore(alembic): resolve potential merge conflict --- ....py => eca999581359_adds_etl_personal_access_token.py} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename alembic/versions/{a960b5652c50_adds_personal_access_token_etl_tables.py => eca999581359_adds_etl_personal_access_token.py} (95%) diff --git a/alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py b/alembic/versions/eca999581359_adds_etl_personal_access_token.py similarity index 95% rename from alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py rename to alembic/versions/eca999581359_adds_etl_personal_access_token.py index e3ac4361..5be03edb 100644 --- a/alembic/versions/a960b5652c50_adds_personal_access_token_etl_tables.py +++ b/alembic/versions/eca999581359_adds_etl_personal_access_token.py @@ -1,8 +1,8 @@ -"""adds personal access token etl tables +"""adds etl personal access token -Revision ID: a960b5652c50 +Revision ID: eca999581359 Revises: 10c48793371d -Create Date: 2025-02-17 09:09:57.859717 +Create Date: 2025-02-20 10:31:15.686683 """ @@ -11,7 +11,7 @@ from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = "a960b5652c50" +revision = "eca999581359" down_revision = "10c48793371d" branch_labels = None depends_on = None From c8009d7ae76b7369306af8662c5b809866d93b6b Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 20 Feb 2025 12:52:48 +0100 Subject: [PATCH 12/21] chore: update submodules --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index 8ddbae72..616de3c2 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 8ddbae72b0cb27d816ee06ba39a63479e698cee1 +Subproject commit 616de3c264b3850704921701ac76ddc9421cb6d6 From 06ca0499347e39d07a57873b4ffa2c85f7f8d7b9 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 20 Feb 2025 22:27:48 +0100 Subject: [PATCH 13/21] chore: update submodules --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index 616de3c2..1f2656be 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 616de3c264b3850704921701ac76ddc9421cb6d6 +Subproject commit 1f2656be1969210c677299b279f77d8a61796173 From 99b0565e4621d56cd377f4ec46502c2579163641 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 20 Feb 2025 22:48:39 +0100 Subject: [PATCH 14/21] chore: update submodules --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index 1f2656be..3d2fe4de 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 1f2656be1969210c677299b279f77d8a61796173 +Subproject commit 3d2fe4de8b0e59ae66dfc543da8d47df3b796ac1 From 76bd86e00d0353edbadacda90a66f34a6cf1a170 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Fri, 21 Feb 2025 15:06:35 +0100 Subject: [PATCH 15/21] perf(alembic): add org_id to pat etl table --- ...c_adds_etl_personal_access_token_table.py} | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) rename alembic/versions/{eca999581359_adds_etl_personal_access_token.py => 32f92724c13c_adds_etl_personal_access_token_table.py} (78%) diff --git a/alembic/versions/eca999581359_adds_etl_personal_access_token.py b/alembic/versions/32f92724c13c_adds_etl_personal_access_token_table.py similarity index 78% rename from alembic/versions/eca999581359_adds_etl_personal_access_token.py rename to alembic/versions/32f92724c13c_adds_etl_personal_access_token_table.py index 5be03edb..391da749 100644 --- a/alembic/versions/eca999581359_adds_etl_personal_access_token.py +++ b/alembic/versions/32f92724c13c_adds_etl_personal_access_token_table.py @@ -1,8 +1,8 @@ -"""adds etl personal access token +"""adds etl personal access token table -Revision ID: eca999581359 +Revision ID: 32f92724c13c Revises: 10c48793371d -Create Date: 2025-02-20 10:31:15.686683 +Create Date: 2025-02-21 14:00:36.605984 """ @@ -11,7 +11,7 @@ from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = "eca999581359" +revision = "32f92724c13c" down_revision = "10c48793371d" branch_labels = None depends_on = None @@ -23,12 +23,16 @@ def upgrade(): "personal_access_token_etl", sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True), + sa.Column("organization_id", postgresql.UUID(as_uuid=True), nullable=True), sa.Column("created_at", sa.DateTime(), nullable=True), sa.Column("name", sa.String(), nullable=True), sa.Column("expires_at", sa.DateTime(), nullable=True), sa.Column("last_used", sa.DateTime(), nullable=True), sa.Column("token", 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", ) @@ -39,6 +43,13 @@ def upgrade(): unique=False, schema="cognition", ) + op.create_index( + op.f("ix_cognition_personal_access_token_etl_organization_id"), + "personal_access_token_etl", + ["organization_id"], + unique=False, + schema="cognition", + ) op.create_table( "personal_access_token_scope_etl", sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), @@ -71,6 +82,11 @@ def downgrade(): schema="cognition", ) op.drop_table("personal_access_token_scope_etl", schema="cognition") + op.drop_index( + op.f("ix_cognition_personal_access_token_etl_organization_id"), + table_name="personal_access_token_etl", + schema="cognition", + ) op.drop_index( op.f("ix_cognition_personal_access_token_etl_created_by"), table_name="personal_access_token_etl", From b0e8c428af16d0cbcf8d92a5a74ab69c6ec52541 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Fri, 21 Feb 2025 15:07:00 +0100 Subject: [PATCH 16/21] chore: update submodules --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index 3d2fe4de..390bfad3 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 3d2fe4de8b0e59ae66dfc543da8d47df3b796ac1 +Subproject commit 390bfad36775f95c53b82c9d20aa80132a8e55fb From 750724f07dd2b73dbdf755d57057c216d187ae4a Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Fri, 21 Feb 2025 15:39:16 +0100 Subject: [PATCH 17/21] chore: update submodules --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index 390bfad3..e26cb26f 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 390bfad36775f95c53b82c9d20aa80132a8e55fb +Subproject commit e26cb26f435212540df602b6c781b06ea7d00e69 From b1522657e6cd00ae2cef8d5edee6b0a433bb8934 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Mon, 24 Feb 2025 10:00:42 +0100 Subject: [PATCH 18/21] chore: update submodules --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index e26cb26f..e92b8274 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit e26cb26f435212540df602b6c781b06ea7d00e69 +Subproject commit e92b827468de30245dcf96617ff88b6421053bc6 From 965e645d799cb281d2c1ce70bcba2aa0a9d8a5bf Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Mon, 24 Feb 2025 10:05:20 +0100 Subject: [PATCH 19/21] chore: update submodules# --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index e92b8274..cfb925be 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit e92b827468de30245dcf96617ff88b6421053bc6 +Subproject commit cfb925bed07fc736d9909d2835e4e2370c6cc4d4 From fb4bd9737598ff18aa305cca1c867ca1973de185 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Mon, 24 Feb 2025 10:12:32 +0100 Subject: [PATCH 20/21] chore: update submodules --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index cfb925be..63ec2fff 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit cfb925bed07fc736d9909d2835e4e2370c6cc4d4 +Subproject commit 63ec2fff9fad373950a95459e8dba04569c1c329 From 54d69837d33ae1eef4d2472b1b6605c6f4cbd506 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Mon, 24 Feb 2025 11:47:41 +0100 Subject: [PATCH 21/21] chore(dev): update submodules --- submodules/model | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/model b/submodules/model index 63ec2fff..cd31a340 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit 63ec2fff9fad373950a95459e8dba04569c1c329 +Subproject commit cd31a340d9a7f1e28c2367a63d36eb71732dec9c