Fix alembic: replace broken no-op initial migration with baseline schema
This commit is contained in:
@@ -1,32 +0,0 @@
|
|||||||
"""initial company os (sqlmodel)
|
|
||||||
|
|
||||||
Revision ID: 157587037601
|
|
||||||
Revises:
|
|
||||||
Create Date: 2026-02-01 23:16:42.890750
|
|
||||||
|
|
||||||
"""
|
|
||||||
from typing import Sequence, Union
|
|
||||||
|
|
||||||
from alembic import op
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
|
||||||
revision: str = '157587037601'
|
|
||||||
down_revision: Union[str, Sequence[str], None] = None
|
|
||||||
branch_labels: Union[str, Sequence[str], None] = None
|
|
||||||
depends_on: Union[str, Sequence[str], None] = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
|
||||||
"""Upgrade schema."""
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
pass
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
|
||||||
"""Downgrade schema."""
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
pass
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
"""hr data model links (onboarding.employee_id, headcount fulfillment, employment action idempotency)
|
|
||||||
|
|
||||||
Revision ID: 2b8d1e2c0d01
|
|
||||||
Revises: 9d3d9b9c1a23
|
|
||||||
Create Date: 2026-02-02 09:05:00.000000
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from alembic import op
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
revision = "2b8d1e2c0d01"
|
|
||||||
down_revision = "9d3d9b9c1a23"
|
|
||||||
branch_labels = None
|
|
||||||
depends_on = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
|
||||||
# headcount_requests fulfillment fields
|
|
||||||
op.add_column("headcount_requests", sa.Column("fulfilled_employee_id", sa.Integer(), nullable=True))
|
|
||||||
op.add_column("headcount_requests", sa.Column("fulfilled_onboarding_id", sa.Integer(), nullable=True))
|
|
||||||
op.add_column("headcount_requests", sa.Column("fulfilled_at", sa.DateTime(), nullable=True))
|
|
||||||
op.create_foreign_key("fk_headcount_fulfilled_employee", "headcount_requests", "employees", ["fulfilled_employee_id"], ["id"])
|
|
||||||
op.create_foreign_key("fk_headcount_fulfilled_onboarding", "headcount_requests", "agent_onboardings", ["fulfilled_onboarding_id"], ["id"])
|
|
||||||
|
|
||||||
# employment_actions idempotency key
|
|
||||||
op.add_column("employment_actions", sa.Column("idempotency_key", sa.String(), nullable=True))
|
|
||||||
op.create_unique_constraint("uq_employment_actions_idempotency_key", "employment_actions", ["idempotency_key"])
|
|
||||||
op.create_index("ix_employment_actions_idempotency_key", "employment_actions", ["idempotency_key"])
|
|
||||||
|
|
||||||
# agent_onboardings employee link
|
|
||||||
op.add_column("agent_onboardings", sa.Column("employee_id", sa.Integer(), nullable=True))
|
|
||||||
op.create_foreign_key("fk_agent_onboardings_employee", "agent_onboardings", "employees", ["employee_id"], ["id"])
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
|
||||||
op.drop_constraint("fk_agent_onboardings_employee", "agent_onboardings", type_="foreignkey")
|
|
||||||
op.drop_column("agent_onboardings", "employee_id")
|
|
||||||
|
|
||||||
op.drop_index("ix_employment_actions_idempotency_key", table_name="employment_actions")
|
|
||||||
op.drop_constraint("uq_employment_actions_idempotency_key", "employment_actions", type_="unique")
|
|
||||||
op.drop_column("employment_actions", "idempotency_key")
|
|
||||||
|
|
||||||
op.drop_constraint("fk_headcount_fulfilled_onboarding", "headcount_requests", type_="foreignkey")
|
|
||||||
op.drop_constraint("fk_headcount_fulfilled_employee", "headcount_requests", type_="foreignkey")
|
|
||||||
op.drop_column("headcount_requests", "fulfilled_at")
|
|
||||||
op.drop_column("headcount_requests", "fulfilled_onboarding_id")
|
|
||||||
op.drop_column("headcount_requests", "fulfilled_employee_id")
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
"""add reply_to_comment_id to task_comments
|
|
||||||
|
|
||||||
Revision ID: 9d3d9b9c1a23
|
|
||||||
Revises: 157587037601
|
|
||||||
Create Date: 2026-02-02 08:15:00.000000
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from alembic import op
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
|
||||||
revision = "9d3d9b9c1a23"
|
|
||||||
down_revision = "157587037601"
|
|
||||||
branch_labels = None
|
|
||||||
depends_on = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
|
||||||
op.add_column("task_comments", sa.Column("reply_to_comment_id", sa.Integer(), nullable=True))
|
|
||||||
op.create_foreign_key(
|
|
||||||
"fk_task_comments_reply_to_comment_id",
|
|
||||||
"task_comments",
|
|
||||||
"task_comments",
|
|
||||||
["reply_to_comment_id"],
|
|
||||||
["id"],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
|
||||||
op.drop_constraint("fk_task_comments_reply_to_comment_id", "task_comments", type_="foreignkey")
|
|
||||||
op.drop_column("task_comments", "reply_to_comment_id")
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
"""employee_openclaw_routing_fields
|
|
||||||
|
|
||||||
Revision ID: b8810dd52471
|
|
||||||
Revises: 2b8d1e2c0d01
|
|
||||||
Create Date: 2026-02-02 16:03:56.528787
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from typing import Sequence, Union
|
|
||||||
|
|
||||||
import sqlalchemy as sa
|
|
||||||
from alembic import op
|
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
|
||||||
revision: str = "b8810dd52471"
|
|
||||||
down_revision: Union[str, Sequence[str], None] = "2b8d1e2c0d01"
|
|
||||||
branch_labels: Union[str, Sequence[str], None] = None
|
|
||||||
depends_on: Union[str, Sequence[str], None] = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
|
||||||
"""Upgrade schema."""
|
|
||||||
op.add_column("employees", sa.Column("openclaw_session_key", sa.String(), nullable=True))
|
|
||||||
op.add_column("employees", sa.Column("notify_enabled", sa.Boolean(), nullable=False, server_default=sa.true()))
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
|
||||||
"""Downgrade schema."""
|
|
||||||
op.drop_column("employees", "notify_enabled")
|
|
||||||
op.drop_column("employees", "openclaw_session_key")
|
|
||||||
179
backend/alembic/versions/bacd5e6a253d_baseline_schema.py
Normal file
179
backend/alembic/versions/bacd5e6a253d_baseline_schema.py
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
"""baseline schema
|
||||||
|
|
||||||
|
Revision ID: bacd5e6a253d
|
||||||
|
Revises:
|
||||||
|
Create Date: 2026-02-02 16:37:34.122971
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
import sqlmodel
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = 'bacd5e6a253d'
|
||||||
|
down_revision: Union[str, Sequence[str], None] = None
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('departments',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('head_employee_id', sa.Integer(), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_index(op.f('ix_departments_name'), 'departments', ['name'], unique=True)
|
||||||
|
op.create_table('employees',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('employee_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('department_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('manager_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('openclaw_session_key', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('notify_enabled', sa.Boolean(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['manager_id'], ['employees.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_foreign_key(None, 'departments', 'employees', ['head_employee_id'], ['id'])
|
||||||
|
op.create_table('projects',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_index(op.f('ix_projects_name'), 'projects', ['name'], unique=True)
|
||||||
|
op.create_table('activities',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('actor_employee_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('entity_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('entity_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('verb', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('payload_json', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['actor_employee_id'], ['employees.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_table('agent_onboardings',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('agent_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('role_title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('prompt', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('cron_interval_ms', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('tools_json', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('owner_hr_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('employee_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('spawned_agent_id', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('session_key', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('notes', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['owner_hr_id'], ['employees.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_table('employment_actions',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('employee_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('issued_by_employee_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('action_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('notes', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('idempotency_key', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['issued_by_employee_id'], ['employees.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_index(op.f('ix_employment_actions_idempotency_key'), 'employment_actions', ['idempotency_key'], unique=True)
|
||||||
|
op.create_table('project_members',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('project_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('employee_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('role', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_table('tasks',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('project_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('description', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('assignee_employee_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('reviewer_employee_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('created_by_employee_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['assignee_employee_id'], ['employees.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['created_by_employee_id'], ['employees.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['reviewer_employee_id'], ['employees.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_index(op.f('ix_tasks_project_id'), 'tasks', ['project_id'], unique=False)
|
||||||
|
op.create_index(op.f('ix_tasks_status'), 'tasks', ['status'], unique=False)
|
||||||
|
op.create_table('headcount_requests',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('department_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('requested_by_manager_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('role_title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('employee_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('quantity', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('justification', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
|
||||||
|
sa.Column('status', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('fulfilled_employee_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('fulfilled_onboarding_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('fulfilled_at', sa.DateTime(), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['fulfilled_employee_id'], ['employees.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['fulfilled_onboarding_id'], ['agent_onboardings.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['requested_by_manager_id'], ['employees.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_table('task_comments',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('task_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('author_employee_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('reply_to_comment_id', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('body', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||||
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['author_employee_id'], ['employees.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['reply_to_comment_id'], ['task_comments.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_index(op.f('ix_task_comments_task_id'), 'task_comments', ['task_id'], unique=False)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_index(op.f('ix_task_comments_task_id'), table_name='task_comments')
|
||||||
|
op.drop_table('task_comments')
|
||||||
|
op.drop_table('headcount_requests')
|
||||||
|
op.drop_index(op.f('ix_tasks_status'), table_name='tasks')
|
||||||
|
op.drop_index(op.f('ix_tasks_project_id'), table_name='tasks')
|
||||||
|
op.drop_table('tasks')
|
||||||
|
op.drop_table('project_members')
|
||||||
|
op.drop_index(op.f('ix_employment_actions_idempotency_key'), table_name='employment_actions')
|
||||||
|
op.drop_table('employment_actions')
|
||||||
|
op.drop_table('agent_onboardings')
|
||||||
|
op.drop_table('activities')
|
||||||
|
op.drop_index(op.f('ix_projects_name'), table_name='projects')
|
||||||
|
op.drop_table('projects')
|
||||||
|
op.drop_table('employees')
|
||||||
|
op.drop_index(op.f('ix_departments_name'), table_name='departments')
|
||||||
|
op.drop_table('departments')
|
||||||
|
# ### end Alembic commands ###
|
||||||
Reference in New Issue
Block a user