repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | """Initial migration |
| #2 | |
| #3 | Revision ID: 0b53c747049a |
| #4 | Revises: |
| #5 | Create Date: 2025-04-19 00:59:56.244203 |
| #6 | |
| #7 | """ |
| #8 | from typing import Sequence, Union |
| #9 | |
| #10 | import sqlalchemy as sa |
| #11 | from alembic import op |
| #12 | |
| #13 | # revision identifiers, used by Alembic. |
| #14 | revision: str = '0b53c747049a' |
| #15 | down_revision: Union[str, None] = None |
| #16 | branch_labels: Union[str, Sequence[str], None] = None |
| #17 | depends_on: Union[str, Sequence[str], None] = None |
| #18 | |
| #19 | |
| #20 | def upgrade() -> None: |
| #21 | """Upgrade schema.""" |
| #22 | # ### commands auto generated by Alembic - please adjust! ### |
| #23 | op.create_table('access_controls', |
| #24 | sa.Column('id', sa.UUID(), nullable=False), |
| #25 | sa.Column('subject_type', sa.String(), nullable=False), |
| #26 | sa.Column('subject_id', sa.UUID(), nullable=True), |
| #27 | sa.Column('object_type', sa.String(), nullable=False), |
| #28 | sa.Column('object_id', sa.UUID(), nullable=True), |
| #29 | sa.Column('effect', sa.String(), nullable=False), |
| #30 | sa.Column('created_at', sa.DateTime(), nullable=True), |
| #31 | sa.PrimaryKeyConstraint('id') |
| #32 | ) |
| #33 | op.create_index('idx_access_object', 'access_controls', ['object_type', 'object_id'], unique=False) |
| #34 | op.create_index('idx_access_subject', 'access_controls', ['subject_type', 'subject_id'], unique=False) |
| #35 | op.create_index(op.f('ix_access_controls_created_at'), 'access_controls', ['created_at'], unique=False) |
| #36 | op.create_index(op.f('ix_access_controls_effect'), 'access_controls', ['effect'], unique=False) |
| #37 | op.create_index(op.f('ix_access_controls_object_id'), 'access_controls', ['object_id'], unique=False) |
| #38 | op.create_index(op.f('ix_access_controls_object_type'), 'access_controls', ['object_type'], unique=False) |
| #39 | op.create_index(op.f('ix_access_controls_subject_id'), 'access_controls', ['subject_id'], unique=False) |
| #40 | op.create_index(op.f('ix_access_controls_subject_type'), 'access_controls', ['subject_type'], unique=False) |
| #41 | op.create_table('archive_policies', |
| #42 | sa.Column('id', sa.UUID(), nullable=False), |
| #43 | sa.Column('criteria_type', sa.String(), nullable=False), |
| #44 | sa.Column('criteria_id', sa.UUID(), nullable=True), |
| #45 | sa.Column('days_to_archive', sa.Integer(), nullable=False), |
| #46 | sa.Column('created_at', sa.DateTime(), nullable=True), |
| #47 | sa.PrimaryKeyConstraint('id') |
| #48 | ) |
| #49 | op.create_index('idx_policy_criteria', 'archive_policies', ['criteria_type', 'criteria_id'], unique=False) |
| #50 | op.create_index(op.f('ix_archive_policies_created_at'), 'archive_policies', ['created_at'], unique=False) |
| #51 | op.create_index(op.f('ix_archive_policies_criteria_id'), 'archive_policies', ['criteria_id'], unique=False) |
| #52 | op.create_index(op.f('ix_archive_policies_criteria_type'), 'archive_policies', ['criteria_type'], unique=False) |
| #53 | op.create_table('categories', |
| #54 | sa.Column('id', sa.UUID(), nullable=False), |
| #55 | sa.Column('name', sa.String(), nullable=False), |
| #56 | sa.Column('description', sa.String(), nullable=True), |
| #57 | sa.Column('created_at', sa.DateTime(), nullable=True), |
| #58 | sa.Column('updated_at', sa.DateTime(), nullable=True), |
| #59 | sa.PrimaryKeyConstraint('id') |
| #60 | ) |
| #61 | op.create_index(op.f('ix_categories_created_at'), 'categories', ['created_at'], unique=False) |
| #62 | op.create_index(op.f('ix_categories_name'), 'categories', ['name'], unique=True) |
| #63 | op.create_table('users', |
| #64 | sa.Column('id', sa.UUID(), nullable=False), |
| #65 | sa.Column('user_id', sa.String(), nullable=False), |
| #66 | sa.Column('name', sa.String(), nullable=True), |
| #67 | sa.Column('email', sa.String(), nullable=True), |
| #68 | sa.Column('metadata', sa.JSON(), nullable=True), |
| #69 | sa.Column('created_at', sa.DateTime(), nullable=True), |
| #70 | sa.Column('updated_at', sa.DateTime(), nullable=True), |
| #71 | sa.PrimaryKeyConstraint('id') |
| #72 | ) |
| #73 | op.create_index(op.f('ix_users_created_at'), 'users', ['created_at'], unique=False) |
| #74 | op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) |
| #75 | op.create_index(op.f('ix_users_name'), 'users', ['name'], unique=False) |
| #76 | op.create_index(op.f('ix_users_user_id'), 'users', ['user_id'], unique=True) |
| #77 | op.create_table('apps', |
| #78 | sa.Column('id', sa.UUID(), nullable=False), |
| #79 | sa.Column('owner_id', sa.UUID(), nullable=False), |
| #80 | sa.Column('name', sa.String(), nullable=False), |
| #81 | sa.Column('description', sa.String(), nullable=True), |
| #82 | sa.Column('metadata', sa.JSON(), nullable=True), |
| #83 | sa.Column('is_active', sa.Boolean(), nullable=True), |
| #84 | sa.Column('created_at', sa.DateTime(), nullable=True), |
| #85 | sa.Column('updated_at', sa.DateTime(), nullable=True), |
| #86 | sa.ForeignKeyConstraint(['owner_id'], ['users.id'], ), |
| #87 | sa.PrimaryKeyConstraint('id') |
| #88 | ) |
| #89 | op.create_index(op.f('ix_apps_created_at'), 'apps', ['created_at'], unique=False) |
| #90 | op.create_index(op.f('ix_apps_is_active'), 'apps', ['is_active'], unique=False) |
| #91 | op.create_index(op.f('ix_apps_name'), 'apps', ['name'], unique=True) |
| #92 | op.create_index(op.f('ix_apps_owner_id'), 'apps', ['owner_id'], unique=False) |
| #93 | op.create_table('memories', |
| #94 | sa.Column('id', sa.UUID(), nullable=False), |
| #95 | sa.Column('user_id', sa.UUID(), nullable=False), |
| #96 | sa.Column('app_id', sa.UUID(), nullable=False), |
| #97 | sa.Column('content', sa.String(), nullable=False), |
| #98 | sa.Column('vector', sa.String(), nullable=True), |
| #99 | sa.Column('metadata', sa.JSON(), nullable=True), |
| #100 | sa.Column('state', sa.Enum('active', 'paused', 'archived', 'deleted', name='memorystate'), nullable=True), |
| #101 | sa.Column('created_at', sa.DateTime(), nullable=True), |
| #102 | sa.Column('updated_at', sa.DateTime(), nullable=True), |
| #103 | sa.Column('archived_at', sa.DateTime(), nullable=True), |
| #104 | sa.Column('deleted_at', sa.DateTime(), nullable=True), |
| #105 | sa.ForeignKeyConstraint(['app_id'], ['apps.id'], ), |
| #106 | sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), |
| #107 | sa.PrimaryKeyConstraint('id') |
| #108 | ) |
| #109 | op.create_index('idx_memory_app_state', 'memories', ['app_id', 'state'], unique=False) |
| #110 | op.create_index('idx_memory_user_app', 'memories', ['user_id', 'app_id'], unique=False) |
| #111 | op.create_index('idx_memory_user_state', 'memories', ['user_id', 'state'], unique=False) |
| #112 | op.create_index(op.f('ix_memories_app_id'), 'memories', ['app_id'], unique=False) |
| #113 | op.create_index(op.f('ix_memories_archived_at'), 'memories', ['archived_at'], unique=False) |
| #114 | op.create_index(op.f('ix_memories_created_at'), 'memories', ['created_at'], unique=False) |
| #115 | op.create_index(op.f('ix_memories_deleted_at'), 'memories', ['deleted_at'], unique=False) |
| #116 | op.create_index(op.f('ix_memories_state'), 'memories', ['state'], unique=False) |
| #117 | op.create_index(op.f('ix_memories_user_id'), 'memories', ['user_id'], unique=False) |
| #118 | op.create_table('memory_access_logs', |
| #119 | sa.Column('id', sa.UUID(), nullable=False), |
| #120 | sa.Column('memory_id', sa.UUID(), nullable=False), |
| #121 | sa.Column('app_id', sa.UUID(), nullable=False), |
| #122 | sa.Column('accessed_at', sa.DateTime(), nullable=True), |
| #123 | sa.Column('access_type', sa.String(), nullable=False), |
| #124 | sa.Column('metadata', sa.JSON(), nullable=True), |
| #125 | sa.ForeignKeyConstraint(['app_id'], ['apps.id'], ), |
| #126 | sa.ForeignKeyConstraint(['memory_id'], ['memories.id'], ), |
| #127 | sa.PrimaryKeyConstraint('id') |
| #128 | ) |
| #129 | op.create_index('idx_access_app_time', 'memory_access_logs', ['app_id', 'accessed_at'], unique=False) |
| #130 | op.create_index('idx_access_memory_time', 'memory_access_logs', ['memory_id', 'accessed_at'], unique=False) |
| #131 | op.create_index(op.f('ix_memory_access_logs_access_type'), 'memory_access_logs', ['access_type'], unique=False) |
| #132 | op.create_index(op.f('ix_memory_access_logs_accessed_at'), 'memory_access_logs', ['accessed_at'], unique=False) |
| #133 | op.create_index(op.f('ix_memory_access_logs_app_id'), 'memory_access_logs', ['app_id'], unique=False) |
| #134 | op.create_index(op.f('ix_memory_access_logs_memory_id'), 'memory_access_logs', ['memory_id'], unique=False) |
| #135 | op.create_table('memory_categories', |
| #136 | sa.Column('memory_id', sa.UUID(), nullable=False), |
| #137 | sa.Column('category_id', sa.UUID(), nullable=False), |
| #138 | sa.ForeignKeyConstraint(['category_id'], ['categories.id'], ), |
| #139 | sa.ForeignKeyConstraint(['memory_id'], ['memories.id'], ), |
| #140 | sa.PrimaryKeyConstraint('memory_id', 'category_id') |
| #141 | ) |
| #142 | op.create_index('idx_memory_category', 'memory_categories', ['memory_id', 'category_id'], unique=False) |
| #143 | op.create_index(op.f('ix_memory_categories_category_id'), 'memory_categories', ['category_id'], unique=False) |
| #144 | op.create_index(op.f('ix_memory_categories_memory_id'), 'memory_categories', ['memory_id'], unique=False) |
| #145 | op.create_table('memory_status_history', |
| #146 | sa.Column('id', sa.UUID(), nullable=False), |
| #147 | sa.Column('memory_id', sa.UUID(), nullable=False), |
| #148 | sa.Column('changed_by', sa.UUID(), nullable=False), |
| #149 | sa.Column('old_state', sa.Enum('active', 'paused', 'archived', 'deleted', name='memorystate'), nullable=False), |
| #150 | sa.Column('new_state', sa.Enum('active', 'paused', 'archived', 'deleted', name='memorystate'), nullable=False), |
| #151 | sa.Column('changed_at', sa.DateTime(), nullable=True), |
| #152 | sa.ForeignKeyConstraint(['changed_by'], ['users.id'], ), |
| #153 | sa.ForeignKeyConstraint(['memory_id'], ['memories.id'], ), |
| #154 | sa.PrimaryKeyConstraint('id') |
| #155 | ) |
| #156 | op.create_index('idx_history_memory_state', 'memory_status_history', ['memory_id', 'new_state'], unique=False) |
| #157 | op.create_index('idx_history_user_time', 'memory_status_history', ['changed_by', 'changed_at'], unique=False) |
| #158 | op.create_index(op.f('ix_memory_status_history_changed_at'), 'memory_status_history', ['changed_at'], unique=False) |
| #159 | op.create_index(op.f('ix_memory_status_history_changed_by'), 'memory_status_history', ['changed_by'], unique=False) |
| #160 | op.create_index(op.f('ix_memory_status_history_memory_id'), 'memory_status_history', ['memory_id'], unique=False) |
| #161 | op.create_index(op.f('ix_memory_status_history_new_state'), 'memory_status_history', ['new_state'], unique=False) |
| #162 | op.create_index(op.f('ix_memory_status_history_old_state'), 'memory_status_history', ['old_state'], unique=False) |
| #163 | # ### end Alembic commands ### |
| #164 | |
| #165 | |
| #166 | def downgrade() -> None: |
| #167 | """Downgrade schema.""" |
| #168 | # ### commands auto generated by Alembic - please adjust! ### |
| #169 | op.drop_index(op.f('ix_memory_status_history_old_state'), table_name='memory_status_history') |
| #170 | op.drop_index(op.f('ix_memory_status_history_new_state'), table_name='memory_status_history') |
| #171 | op.drop_index(op.f('ix_memory_status_history_memory_id'), table_name='memory_status_history') |
| #172 | op.drop_index(op.f('ix_memory_status_history_changed_by'), table_name='memory_status_history') |
| #173 | op.drop_index(op.f('ix_memory_status_history_changed_at'), table_name='memory_status_history') |
| #174 | op.drop_index('idx_history_user_time', table_name='memory_status_history') |
| #175 | op.drop_index('idx_history_memory_state', table_name='memory_status_history') |
| #176 | op.drop_table('memory_status_history') |
| #177 | op.drop_index(op.f('ix_memory_categories_memory_id'), table_name='memory_categories') |
| #178 | op.drop_index(op.f('ix_memory_categories_category_id'), table_name='memory_categories') |
| #179 | op.drop_index('idx_memory_category', table_name='memory_categories') |
| #180 | op.drop_table('memory_categories') |
| #181 | op.drop_index(op.f('ix_memory_access_logs_memory_id'), table_name='memory_access_logs') |
| #182 | op.drop_index(op.f('ix_memory_access_logs_app_id'), table_name='memory_access_logs') |
| #183 | op.drop_index(op.f('ix_memory_access_logs_accessed_at'), table_name='memory_access_logs') |
| #184 | op.drop_index(op.f('ix_memory_access_logs_access_type'), table_name='memory_access_logs') |
| #185 | op.drop_index('idx_access_memory_time', table_name='memory_access_logs') |
| #186 | op.drop_index('idx_access_app_time', table_name='memory_access_logs') |
| #187 | op.drop_table('memory_access_logs') |
| #188 | op.drop_index(op.f('ix_memories_user_id'), table_name='memories') |
| #189 | op.drop_index(op.f('ix_memories_state'), table_name='memories') |
| #190 | op.drop_index(op.f('ix_memories_deleted_at'), table_name='memories') |
| #191 | op.drop_index(op.f('ix_memories_created_at'), table_name='memories') |
| #192 | op.drop_index(op.f('ix_memories_archived_at'), table_name='memories') |
| #193 | op.drop_index(op.f('ix_memories_app_id'), table_name='memories') |
| #194 | op.drop_index('idx_memory_user_state', table_name='memories') |
| #195 | op.drop_index('idx_memory_user_app', table_name='memories') |
| #196 | op.drop_index('idx_memory_app_state', table_name='memories') |
| #197 | op.drop_table('memories') |
| #198 | op.drop_index(op.f('ix_apps_owner_id'), table_name='apps') |
| #199 | op.drop_index(op.f('ix_apps_name'), table_name='apps') |
| #200 | op.drop_index(op.f('ix_apps_is_active'), table_name='apps') |
| #201 | op.drop_index(op.f('ix_apps_created_at'), table_name='apps') |
| #202 | op.drop_table('apps') |
| #203 | op.drop_index(op.f('ix_users_user_id'), table_name='users') |
| #204 | op.drop_index(op.f('ix_users_name'), table_name='users') |
| #205 | op.drop_index(op.f('ix_users_email'), table_name='users') |
| #206 | op.drop_index(op.f('ix_users_created_at'), table_name='users') |
| #207 | op.drop_table('users') |
| #208 | op.drop_index(op.f('ix_categories_name'), table_name='categories') |
| #209 | op.drop_index(op.f('ix_categories_created_at'), table_name='categories') |
| #210 | op.drop_table('categories') |
| #211 | op.drop_index(op.f('ix_archive_policies_criteria_type'), table_name='archive_policies') |
| #212 | op.drop_index(op.f('ix_archive_policies_criteria_id'), table_name='archive_policies') |
| #213 | op.drop_index(op.f('ix_archive_policies_created_at'), table_name='archive_policies') |
| #214 | op.drop_index('idx_policy_criteria', table_name='archive_policies') |
| #215 | op.drop_table('archive_policies') |
| #216 | op.drop_index(op.f('ix_access_controls_subject_type'), table_name='access_controls') |
| #217 | op.drop_index(op.f('ix_access_controls_subject_id'), table_name='access_controls') |
| #218 | op.drop_index(op.f('ix_access_controls_object_type'), table_name='access_controls') |
| #219 | op.drop_index(op.f('ix_access_controls_object_id'), table_name='access_controls') |
| #220 | op.drop_index(op.f('ix_access_controls_effect'), table_name='access_controls') |
| #221 | op.drop_index(op.f('ix_access_controls_created_at'), table_name='access_controls') |
| #222 | op.drop_index('idx_access_subject', table_name='access_controls') |
| #223 | op.drop_index('idx_access_object', table_name='access_controls') |
| #224 | op.drop_table('access_controls') |
| #225 | # ### end Alembic commands ### |
| #226 |