Rename the import package app to fluksio
A wheel whose top-level module is `app` collides with anything else in a user's venv, so the package that is about to be published takes the name it is published under. Only the Python package moves; the repo, the Docker WORKDIR and the compose project keep theirs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+1
@@ -0,0 +1 @@
|
||||
Generic single-database configuration.
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
import os
|
||||
from logging.config import fileConfig
|
||||
|
||||
from alembic import context
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
config = context.config
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
# target_metadata = None
|
||||
|
||||
from fluksio.models import SQLModel # noqa
|
||||
from fluksio.core.config import settings # noqa
|
||||
|
||||
target_metadata = SQLModel.metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
# my_important_option = config.get_main_option("my_important_option")
|
||||
# ... etc.
|
||||
|
||||
|
||||
def get_url():
|
||||
return str(settings.SQLALCHEMY_DATABASE_URI)
|
||||
|
||||
|
||||
def run_migrations_offline():
|
||||
"""Run migrations in 'offline' mode.
|
||||
|
||||
This configures the context with just a URL
|
||||
and not an Engine, though an Engine is acceptable
|
||||
here as well. By skipping the Engine creation
|
||||
we don't even need a DBAPI to be available.
|
||||
|
||||
Calls to context.execute() here emit the given string to the
|
||||
script output.
|
||||
|
||||
"""
|
||||
url = get_url()
|
||||
context.configure(
|
||||
url=url, target_metadata=target_metadata, literal_binds=True, compare_type=True
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def run_migrations_online():
|
||||
"""Run migrations in 'online' mode.
|
||||
|
||||
In this scenario we need to create an Engine
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
configuration = config.get_section(config.config_ini_section)
|
||||
configuration["sqlalchemy.url"] = get_url()
|
||||
connectable = engine_from_config(
|
||||
configuration,
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection, target_metadata=target_metadata, compare_type=True
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = ${repr(up_revision)}
|
||||
down_revision = ${repr(down_revision)}
|
||||
branch_labels = ${repr(branch_labels)}
|
||||
depends_on = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade():
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade():
|
||||
${downgrades if downgrades else "pass"}
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
"""Add observability rollups, events and runs
|
||||
|
||||
Revision ID: 087c44e16304
|
||||
Revises: 59e2606ce144
|
||||
Create Date: 2026-08-16 19:55:10.772691
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '087c44e16304'
|
||||
down_revision = '59e2606ce144'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('engine_event',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('ts', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('type', sqlmodel.sql.sqltypes.AutoString(length=32), nullable=False),
|
||||
sa.Column('flow', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('node', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('detail', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('actor', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_engine_event_ts'), 'engine_event', ['ts'], unique=False)
|
||||
op.create_index(op.f('ix_engine_event_type'), 'engine_event', ['type'], unique=False)
|
||||
op.create_table('flow_run',
|
||||
sa.Column('id', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('flow', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
|
||||
sa.Column('source', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('started_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('finished_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('nodes', sa.Integer(), nullable=False),
|
||||
sa.Column('errors', sa.Integer(), nullable=False),
|
||||
sa.Column('duration_ms', sa.Float(), nullable=False),
|
||||
sa.Column('deliveries', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_flow_run_flow'), 'flow_run', ['flow'], unique=False)
|
||||
op.create_index(op.f('ix_flow_run_started_at'), 'flow_run', ['started_at'], unique=False)
|
||||
op.create_table('metric_minute',
|
||||
sa.Column('flow', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
|
||||
sa.Column('node', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
|
||||
sa.Column('bucket', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('executions', sa.Integer(), nullable=False),
|
||||
sa.Column('errors', sa.Integer(), nullable=False),
|
||||
sa.Column('messages', sa.Integer(), nullable=False),
|
||||
sa.Column('duration_sum_ms', sa.Float(), nullable=False),
|
||||
sa.Column('duration_max_ms', sa.Float(), nullable=False),
|
||||
sa.Column('lag_sum_ms', sa.Float(), nullable=False),
|
||||
sa.Column('lag_max_ms', sa.Float(), nullable=False),
|
||||
sa.Column('items', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('flow', 'node', 'bucket')
|
||||
)
|
||||
op.create_index(op.f('ix_metric_minute_bucket'), 'metric_minute', ['bucket'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_metric_minute_bucket'), table_name='metric_minute')
|
||||
op.drop_table('metric_minute')
|
||||
op.drop_index(op.f('ix_flow_run_started_at'), table_name='flow_run')
|
||||
op.drop_index(op.f('ix_flow_run_flow'), table_name='flow_run')
|
||||
op.drop_table('flow_run')
|
||||
op.drop_index(op.f('ix_engine_event_type'), table_name='engine_event')
|
||||
op.drop_index(op.f('ix_engine_event_ts'), table_name='engine_event')
|
||||
op.drop_table('engine_event')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,37 @@
|
||||
"""Add cascade delete relationships
|
||||
|
||||
Revision ID: 1a31ce608336
|
||||
Revises: d98dd8ec85a3
|
||||
Create Date: 2024-07-31 22:24:34.447891
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1a31ce608336'
|
||||
down_revision = 'd98dd8ec85a3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('item', 'owner_id',
|
||||
existing_type=sa.UUID(),
|
||||
nullable=False)
|
||||
op.drop_constraint('item_owner_id_fkey', 'item', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'item', 'user', ['owner_id'], ['id'], ondelete='CASCADE')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'item', type_='foreignkey')
|
||||
op.create_foreign_key('item_owner_id_fkey', 'item', 'user', ['owner_id'], ['id'])
|
||||
op.alter_column('item', 'owner_id',
|
||||
existing_type=sa.UUID(),
|
||||
nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
"""add oauth client, code and refresh token
|
||||
|
||||
Revision ID: 59e2606ce144
|
||||
Revises: b7c41d2f8a30
|
||||
Create Date: 2026-08-15 23:59:41.147202
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '59e2606ce144'
|
||||
down_revision = 'b7c41d2f8a30'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('oauth_client',
|
||||
sa.Column('id', sa.Uuid(), nullable=False),
|
||||
sa.Column('client_name', sqlmodel.sql.sqltypes.AutoString(length=128), nullable=False),
|
||||
sa.Column('redirect_uris', sa.JSON(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('oauth_authorization_code',
|
||||
sa.Column('id', sa.Uuid(), nullable=False),
|
||||
sa.Column('code_hash', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('client_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('user_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('redirect_uri', sqlmodel.sql.sqltypes.AutoString(length=2048), nullable=False),
|
||||
sa.Column('code_challenge', sqlmodel.sql.sqltypes.AutoString(length=128), nullable=False),
|
||||
sa.Column('resource', sqlmodel.sql.sqltypes.AutoString(length=2048), nullable=True),
|
||||
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('used_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('refresh_token_id', sa.Uuid(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['client_id'], ['oauth_client.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_oauth_authorization_code_code_hash'), 'oauth_authorization_code', ['code_hash'], unique=True)
|
||||
op.create_table('oauth_refresh_token',
|
||||
sa.Column('id', sa.Uuid(), nullable=False),
|
||||
sa.Column('token_hash', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('client_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('user_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('family_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('revoked', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['client_id'], ['oauth_client.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_oauth_refresh_token_token_hash'), 'oauth_refresh_token', ['token_hash'], unique=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_oauth_refresh_token_token_hash'), table_name='oauth_refresh_token')
|
||||
op.drop_table('oauth_refresh_token')
|
||||
op.drop_index(op.f('ix_oauth_authorization_code_code_hash'), table_name='oauth_authorization_code')
|
||||
op.drop_table('oauth_authorization_code')
|
||||
op.drop_table('oauth_client')
|
||||
# ### end Alembic commands ###
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
"""Add max length for string(varchar) fields in User and Items models
|
||||
|
||||
Revision ID: 9c0a54914c78
|
||||
Revises: e2412789c190
|
||||
Create Date: 2024-06-17 14:42:44.639457
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9c0a54914c78'
|
||||
down_revision = 'e2412789c190'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Adjust the length of the email field in the User table
|
||||
op.alter_column('user', 'email',
|
||||
existing_type=sa.String(),
|
||||
type_=sa.String(length=255),
|
||||
existing_nullable=False)
|
||||
|
||||
# Adjust the length of the full_name field in the User table
|
||||
op.alter_column('user', 'full_name',
|
||||
existing_type=sa.String(),
|
||||
type_=sa.String(length=255),
|
||||
existing_nullable=True)
|
||||
|
||||
# Adjust the length of the title field in the Item table
|
||||
op.alter_column('item', 'title',
|
||||
existing_type=sa.String(),
|
||||
type_=sa.String(length=255),
|
||||
existing_nullable=False)
|
||||
|
||||
# Adjust the length of the description field in the Item table
|
||||
op.alter_column('item', 'description',
|
||||
existing_type=sa.String(),
|
||||
type_=sa.String(length=255),
|
||||
existing_nullable=True)
|
||||
|
||||
|
||||
def downgrade():
|
||||
# Revert the length of the email field in the User table
|
||||
op.alter_column('user', 'email',
|
||||
existing_type=sa.String(length=255),
|
||||
type_=sa.String(),
|
||||
existing_nullable=False)
|
||||
|
||||
# Revert the length of the full_name field in the User table
|
||||
op.alter_column('user', 'full_name',
|
||||
existing_type=sa.String(length=255),
|
||||
type_=sa.String(),
|
||||
existing_nullable=True)
|
||||
|
||||
# Revert the length of the title field in the Item table
|
||||
op.alter_column('item', 'title',
|
||||
existing_type=sa.String(length=255),
|
||||
type_=sa.String(),
|
||||
existing_nullable=False)
|
||||
|
||||
# Revert the length of the description field in the Item table
|
||||
op.alter_column('item', 'description',
|
||||
existing_type=sa.String(length=255),
|
||||
type_=sa.String(),
|
||||
existing_nullable=True)
|
||||
@@ -0,0 +1,126 @@
|
||||
"""Add run, run_node, run_metric and run_artifact
|
||||
|
||||
Runs are the batch shape of the engine: a flow taken from its inputs to its
|
||||
outputs once, with parameters that identify it and a result worth keeping.
|
||||
Deliberately its own tables rather than columns on flow_run — a cascade row is
|
||||
rolled up and pruned on a retention window, and an experiment must not be.
|
||||
|
||||
Revision ID: a3f1c07b52d9
|
||||
Revises: 087c44e16304
|
||||
Create Date: 2026-08-18 09:12:44.108312
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a3f1c07b52d9'
|
||||
down_revision = '087c44e16304'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'run',
|
||||
sa.Column('id', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('flow', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
|
||||
sa.Column('flow_version', sa.Integer(), nullable=False),
|
||||
sa.Column('commit', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('params', sa.JSON(), nullable=True),
|
||||
sa.Column(
|
||||
'params_digest',
|
||||
sqlmodel.sql.sqltypes.AutoString(length=64),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column('seed', sa.Integer(), nullable=True),
|
||||
sa.Column('group_id', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=True),
|
||||
sa.Column('parent_id', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=True),
|
||||
sa.Column('cause', sqlmodel.sql.sqltypes.AutoString(length=32), nullable=False),
|
||||
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(length=16), nullable=False),
|
||||
sa.Column(
|
||||
'status_reason',
|
||||
sqlmodel.sql.sqltypes.AutoString(length=1024),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column('labels', sa.JSON(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('started_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('finished_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('duration_ms', sa.Float(), nullable=False),
|
||||
sa.Column('result', sa.JSON(), nullable=True),
|
||||
sa.Column('engine', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('lease_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('actor', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
)
|
||||
op.create_index(op.f('ix_run_flow'), 'run', ['flow'], unique=False)
|
||||
op.create_index(op.f('ix_run_status'), 'run', ['status'], unique=False)
|
||||
op.create_index(op.f('ix_run_group_id'), 'run', ['group_id'], unique=False)
|
||||
op.create_index(op.f('ix_run_created_at'), 'run', ['created_at'], unique=False)
|
||||
op.create_index(
|
||||
op.f('ix_run_params_digest'), 'run', ['params_digest'], unique=False
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'run_node',
|
||||
sa.Column('run_id', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('node', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
|
||||
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(length=16), nullable=False),
|
||||
sa.Column('attempt', sa.Integer(), nullable=False),
|
||||
sa.Column('started_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('duration_ms', sa.Float(), nullable=False),
|
||||
sa.Column('worker', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('error', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('logs', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column(
|
||||
'cache_key', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False
|
||||
),
|
||||
sa.PrimaryKeyConstraint('run_id', 'node'),
|
||||
)
|
||||
op.create_index(
|
||||
op.f('ix_run_node_cache_key'), 'run_node', ['cache_key'], unique=False
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'run_metric',
|
||||
sa.Column('run_id', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(length=128), nullable=False),
|
||||
sa.Column('step', sa.Integer(), nullable=False),
|
||||
sa.Column('node', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
|
||||
sa.Column('ts', sa.Float(), nullable=False),
|
||||
sa.Column('value', sa.Float(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('run_id', 'name', 'step'),
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'run_artifact',
|
||||
sa.Column('run_id', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=False),
|
||||
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
|
||||
sa.Column('node', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False),
|
||||
sa.Column('digest', sqlmodel.sql.sqltypes.AutoString(length=71), nullable=False),
|
||||
sa.Column('size', sa.BigInteger(), nullable=False),
|
||||
sa.Column(
|
||||
'media_type', sqlmodel.sql.sqltypes.AutoString(length=128), nullable=False
|
||||
),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.PrimaryKeyConstraint('run_id', 'name'),
|
||||
)
|
||||
op.create_index(
|
||||
op.f('ix_run_artifact_digest'), 'run_artifact', ['digest'], unique=False
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(op.f('ix_run_artifact_digest'), table_name='run_artifact')
|
||||
op.drop_table('run_artifact')
|
||||
op.drop_table('run_metric')
|
||||
op.drop_index(op.f('ix_run_node_cache_key'), table_name='run_node')
|
||||
op.drop_table('run_node')
|
||||
op.drop_index(op.f('ix_run_params_digest'), table_name='run')
|
||||
op.drop_index(op.f('ix_run_created_at'), table_name='run')
|
||||
op.drop_index(op.f('ix_run_group_id'), table_name='run')
|
||||
op.drop_index(op.f('ix_run_status'), table_name='run')
|
||||
op.drop_index(op.f('ix_run_flow'), table_name='run')
|
||||
op.drop_table('run')
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Drop the item table
|
||||
|
||||
The template's example model. Flows are persisted as files in their own git
|
||||
repository, so nothing in the app uses it any more.
|
||||
|
||||
Revision ID: b7c41d2f8a30
|
||||
Revises: fe56fa70289e
|
||||
Create Date: 2026-08-15
|
||||
|
||||
"""
|
||||
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
from alembic import op
|
||||
|
||||
revision = "b7c41d2f8a30"
|
||||
down_revision = "fe56fa70289e"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_table("item")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.create_table(
|
||||
"item",
|
||||
sa.Column("id", sa.Uuid(), nullable=False),
|
||||
sa.Column(
|
||||
"title", sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False
|
||||
),
|
||||
sa.Column(
|
||||
"description", sqlmodel.sql.sqltypes.AutoString(length=255), nullable=True
|
||||
),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("owner_id", sa.Uuid(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["owner_id"], ["user.id"], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Map local accounts to the portal identities they stand for
|
||||
|
||||
A portal session used to act as whoever enrolled this installation. It now
|
||||
names a person, and this column is where that name meets a local account: set
|
||||
for the enrolling superuser at enrolment, and for every remote user a superuser
|
||||
admits afterwards. Unique, because two local accounts standing for the same
|
||||
portal identity would make the lookup a coin toss.
|
||||
|
||||
Revision ID: c4e8b2170f93
|
||||
Revises: a3f1c07b52d9
|
||||
Create Date: 2026-08-21 10:42:07.512004
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c4e8b2170f93'
|
||||
down_revision = 'a3f1c07b52d9'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column(
|
||||
'user',
|
||||
sa.Column('portal_sub', sqlmodel.sql.sqltypes.AutoString(length=64), nullable=True),
|
||||
)
|
||||
op.create_index(op.f('ix_user_portal_sub'), 'user', ['portal_sub'], unique=True)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(op.f('ix_user_portal_sub'), table_name='user')
|
||||
op.drop_column('user', 'portal_sub')
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
"""Edit replace id integers in all models to use UUID instead
|
||||
|
||||
Revision ID: d98dd8ec85a3
|
||||
Revises: 9c0a54914c78
|
||||
Create Date: 2024-07-19 04:08:04.000976
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd98dd8ec85a3'
|
||||
down_revision = '9c0a54914c78'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Ensure uuid-ossp extension is available
|
||||
op.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"')
|
||||
|
||||
# Create a new UUID column with a default UUID value
|
||||
op.add_column('user', sa.Column('new_id', postgresql.UUID(as_uuid=True), default=sa.text('uuid_generate_v4()')))
|
||||
op.add_column('item', sa.Column('new_id', postgresql.UUID(as_uuid=True), default=sa.text('uuid_generate_v4()')))
|
||||
op.add_column('item', sa.Column('new_owner_id', postgresql.UUID(as_uuid=True), nullable=True))
|
||||
|
||||
# Populate the new columns with UUIDs
|
||||
op.execute('UPDATE "user" SET new_id = uuid_generate_v4()')
|
||||
op.execute('UPDATE item SET new_id = uuid_generate_v4()')
|
||||
op.execute('UPDATE item SET new_owner_id = (SELECT new_id FROM "user" WHERE "user".id = item.owner_id)')
|
||||
|
||||
# Set the new_id as not nullable
|
||||
op.alter_column('user', 'new_id', nullable=False)
|
||||
op.alter_column('item', 'new_id', nullable=False)
|
||||
|
||||
# Drop old columns and rename new columns
|
||||
op.drop_constraint('item_owner_id_fkey', 'item', type_='foreignkey')
|
||||
op.drop_column('item', 'owner_id')
|
||||
op.alter_column('item', 'new_owner_id', new_column_name='owner_id')
|
||||
|
||||
op.drop_column('user', 'id')
|
||||
op.alter_column('user', 'new_id', new_column_name='id')
|
||||
|
||||
op.drop_column('item', 'id')
|
||||
op.alter_column('item', 'new_id', new_column_name='id')
|
||||
|
||||
# Create primary key constraint
|
||||
op.create_primary_key('user_pkey', 'user', ['id'])
|
||||
op.create_primary_key('item_pkey', 'item', ['id'])
|
||||
|
||||
# Recreate foreign key constraint
|
||||
op.create_foreign_key('item_owner_id_fkey', 'item', 'user', ['owner_id'], ['id'])
|
||||
|
||||
def downgrade():
|
||||
# Reverse the upgrade process
|
||||
op.add_column('user', sa.Column('old_id', sa.Integer, autoincrement=True))
|
||||
op.add_column('item', sa.Column('old_id', sa.Integer, autoincrement=True))
|
||||
op.add_column('item', sa.Column('old_owner_id', sa.Integer, nullable=True))
|
||||
|
||||
# Populate the old columns with default values
|
||||
# Generate sequences for the integer IDs if not exist
|
||||
op.execute('CREATE SEQUENCE IF NOT EXISTS user_id_seq AS INTEGER OWNED BY "user".old_id')
|
||||
op.execute('CREATE SEQUENCE IF NOT EXISTS item_id_seq AS INTEGER OWNED BY item.old_id')
|
||||
|
||||
op.execute('SELECT setval(\'user_id_seq\', COALESCE((SELECT MAX(old_id) + 1 FROM "user"), 1), false)')
|
||||
op.execute('SELECT setval(\'item_id_seq\', COALESCE((SELECT MAX(old_id) + 1 FROM item), 1), false)')
|
||||
|
||||
op.execute('UPDATE "user" SET old_id = nextval(\'user_id_seq\')')
|
||||
op.execute('UPDATE item SET old_id = nextval(\'item_id_seq\'), old_owner_id = (SELECT old_id FROM "user" WHERE "user".id = item.owner_id)')
|
||||
|
||||
# Drop new columns and rename old columns back
|
||||
op.drop_constraint('item_owner_id_fkey', 'item', type_='foreignkey')
|
||||
op.drop_column('item', 'owner_id')
|
||||
op.alter_column('item', 'old_owner_id', new_column_name='owner_id')
|
||||
|
||||
op.drop_column('user', 'id')
|
||||
op.alter_column('user', 'old_id', new_column_name='id')
|
||||
|
||||
op.drop_column('item', 'id')
|
||||
op.alter_column('item', 'old_id', new_column_name='id')
|
||||
|
||||
# Create primary key constraint
|
||||
op.create_primary_key('user_pkey', 'user', ['id'])
|
||||
op.create_primary_key('item_pkey', 'item', ['id'])
|
||||
|
||||
# Recreate foreign key constraint
|
||||
op.create_foreign_key('item_owner_id_fkey', 'item', 'user', ['owner_id'], ['id'])
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Initialize models
|
||||
|
||||
Revision ID: e2412789c190
|
||||
Revises:
|
||||
Create Date: 2023-11-24 22:55:43.195942
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "e2412789c190"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"user",
|
||||
sa.Column("email", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False),
|
||||
sa.Column("is_superuser", sa.Boolean(), nullable=False),
|
||||
sa.Column("full_name", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
"hashed_password", sqlmodel.sql.sqltypes.AutoString(), nullable=False
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(op.f("ix_user_email"), "user", ["email"], unique=True)
|
||||
op.create_table(
|
||||
"item",
|
||||
sa.Column("description", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("title", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column("owner_id", sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
["owner_id"],
|
||||
["user.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table("item")
|
||||
op.drop_index(op.f("ix_user_email"), table_name="user")
|
||||
op.drop_table("user")
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Add created_at to User and Item
|
||||
|
||||
Revision ID: fe56fa70289e
|
||||
Revises: 1a31ce608336
|
||||
Create Date: 2026-01-23 15:50:37.171462
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'fe56fa70289e'
|
||||
down_revision = '1a31ce608336'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('item', sa.Column('created_at', sa.DateTime(timezone=True), nullable=True))
|
||||
op.add_column('user', sa.Column('created_at', sa.DateTime(timezone=True), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('user', 'created_at')
|
||||
op.drop_column('item', 'created_at')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user