Skip to content
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

feat: Implement workflow tags backend #654

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
72 changes: 72 additions & 0 deletions alembic/versions/3bc0a0970817_add_tags_and_workflow_tags_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""Add tags and workflow tags tables

Revision ID: 3bc0a0970817
Revises: da03a0dfa2db
Create Date: 2024-12-23 00:34:49.841129

"""
from collections.abc import Sequence

import sqlalchemy as sa
import sqlmodel.sql.sqltypes

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "3bc0a0970817"
down_revision: str | None = "da03a0dfa2db"
branch_labels: Sequence[str] | None = None
depends_on: Sequence[str] | None = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"tag",
sa.Column("surrogate_id", sa.Integer(), nullable=False),
sa.Column(
"created_at",
sa.TIMESTAMP(timezone=True),
server_default=sa.text("(now() AT TIME ZONE 'utc'::text)"),
nullable=False,
),
sa.Column(
"updated_at",
sa.TIMESTAMP(timezone=True),
server_default=sa.text("(now() AT TIME ZONE 'utc'::text)"),
nullable=False,
),
sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column("owner_id", sa.UUID(), nullable=True),
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("color", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.ForeignKeyConstraint(["owner_id"], ["workspace.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("surrogate_id"),
sa.UniqueConstraint("name", "owner_id"),
)
op.create_index(op.f("ix_tag_id"), "tag", ["id"], unique=True)
op.create_index(op.f("ix_tag_name"), "tag", ["name"], unique=False)
op.create_table(
"workflowtag",
sa.Column("tag_id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column("workflow_id", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.ForeignKeyConstraint(
["tag_id"],
["tag.id"],
),
sa.ForeignKeyConstraint(
["workflow_id"],
["workflow.id"],
),
sa.PrimaryKeyConstraint("tag_id", "workflow_id"),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("workflowtag")
op.drop_index(op.f("ix_tag_name"), table_name="tag")
op.drop_index(op.f("ix_tag_id"), table_name="tag")
op.drop_table("tag")
# ### end Alembic commands ###
107 changes: 107 additions & 0 deletions frontend/src/client/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,86 @@ export const $SessionRead = {
title: 'SessionRead'
} as const;

export const $TagCreate = {
properties: {
name: {
type: 'string',
title: 'Name'
},
color: {
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
],
title: 'Color'
}
},
type: 'object',
required: ['name'],
title: 'TagCreate'
} as const;

export const $TagRead = {
properties: {
id: {
type: 'string',
format: 'uuid4',
title: 'Id'
},
name: {
type: 'string',
title: 'Name'
},
color: {
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
],
title: 'Color'
}
},
type: 'object',
required: ['id', 'name'],
title: 'TagRead'
} as const;

export const $TagUpdate = {
properties: {
name: {
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
],
title: 'Name'
},
color: {
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
],
title: 'Color'
}
},
type: 'object',
title: 'TagUpdate'
} as const;

export const $TemplateAction_Input = {
properties: {
type: {
Expand Down Expand Up @@ -3655,6 +3735,20 @@ export const $WorkflowMetadataResponse = {
}
],
title: 'Version'
},
tags: {
anyOf: [
{
items: {
'$ref': '#/components/schemas/TagRead'
},
type: 'array'
},
{
type: 'null'
}
],
title: 'Tags'
}
},
type: 'object',
Expand Down Expand Up @@ -3772,6 +3866,19 @@ export const $WorkflowResponse = {
title: 'WorkflowResponse'
} as const;

export const $WorkflowTagCreate = {
properties: {
tag_id: {
type: 'string',
format: 'uuid4',
title: 'Tag Id'
}
},
type: 'object',
required: ['tag_id'],
title: 'WorkflowTagCreate'
} as const;

export const $WorkspaceMember = {
properties: {
user_id: {
Expand Down
Loading
Loading