You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2026/07/15 03:37:53 UTC

(airavata-custos) 01/01: Consolidate core database migration files

This is an automated email from the ASF dual-hosted git repository.

lahirujayathilake pushed a commit to branch migrations-update
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git

commit b013dee0d1c49289ae5b35ee9b6190fbe9083c7f
Author: lahiruj <la...@gmail.com>
AuthorDate: Tue Jul 14 23:37:41 2026 -0400

    Consolidate core database migration files
---
 internal/db/migrations/000001_identity.up.sql      |  1 +
 internal/db/migrations/000003_projects.down.sql    |  1 +
 internal/db/migrations/000003_projects.up.sql      | 16 ++++++++
 internal/db/migrations/000004_allocations.up.sql   | 23 ++++++-----
 internal/db/migrations/000005_audit.up.sql         | 23 ++++++++---
 ...oles.down.sql => 000006_authorization.down.sql} |  1 +
 ...08_roles.up.sql => 000006_authorization.up.sql} | 18 +++++++++
 ...06_compute_allocation_resource_cluster.down.sql | 22 ----------
 ...0006_compute_allocation_resource_cluster.up.sql | 23 -----------
 .../db/migrations/000007_user_privileges.down.sql  | 18 ---------
 .../db/migrations/000007_user_privileges.up.sql    | 37 -----------------
 ...000009_update_allocation_usage_columns.down.sql | 21 ----------
 .../000009_update_allocation_usage_columns.up.sql  | 21 ----------
 .../migrations/000010_audit_trace_columns.down.sql | 22 ----------
 .../migrations/000010_audit_trace_columns.up.sql   | 22 ----------
 .../migrations/000011_audit_event_source.down.sql  | 20 ---------
 .../db/migrations/000011_audit_event_source.up.sql | 20 ---------
 .../000012_audit_events_entity_type.down.sql       | 20 ---------
 .../000012_audit_events_entity_type.up.sql         | 22 ----------
 .../db/migrations/000013_membership_role.down.sql  | 20 ---------
 .../db/migrations/000013_membership_role.up.sql    | 23 -----------
 .../migrations/000014_project_memberships.down.sql | 30 --------------
 .../migrations/000014_project_memberships.up.sql   | 47 ----------------------
 internal/db/migrations/000015_user_type.down.sql   | 18 ---------
 internal/db/migrations/000015_user_type.up.sql     | 18 ---------
 25 files changed, 68 insertions(+), 439 deletions(-)

diff --git a/internal/db/migrations/000001_identity.up.sql b/internal/db/migrations/000001_identity.up.sql
index e1db4eca7..071d4436a 100644
--- a/internal/db/migrations/000001_identity.up.sql
+++ b/internal/db/migrations/000001_identity.up.sql
@@ -38,6 +38,7 @@ CREATE TABLE IF NOT EXISTS users
     middle_name     VARCHAR(255) NOT NULL DEFAULT '',
     email           VARCHAR(255) NOT NULL,
     status          VARCHAR(32)  NOT NULL DEFAULT 'PENDING',
+    type            VARCHAR(32)  NOT NULL DEFAULT 'CLUSTER_LOCAL',
     created_at      TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
     updated_at      TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
     PRIMARY KEY (id),
diff --git a/internal/db/migrations/000003_projects.down.sql b/internal/db/migrations/000003_projects.down.sql
index fb20b72d0..34e4a3206 100644
--- a/internal/db/migrations/000003_projects.down.sql
+++ b/internal/db/migrations/000003_projects.down.sql
@@ -15,4 +15,5 @@
 -- specific language governing permissions and limitations
 -- under the License.
 
+DROP TABLE IF EXISTS project_memberships;
 DROP TABLE IF EXISTS projects;
diff --git a/internal/db/migrations/000003_projects.up.sql b/internal/db/migrations/000003_projects.up.sql
index 8dd9cb1a8..b9278a8dc 100644
--- a/internal/db/migrations/000003_projects.up.sql
+++ b/internal/db/migrations/000003_projects.up.sql
@@ -33,3 +33,19 @@ CREATE TABLE IF NOT EXISTS projects
     KEY idx_projects_status (status),
     CONSTRAINT fk_projects_pi FOREIGN KEY (project_pi_id) REFERENCES users (id) ON DELETE RESTRICT
 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
+
+-- Project-level governance roles (PI / CO_PI / ALLOCATION_MANAGER). MEMBER
+-- status is derived from compute_allocation_memberships, so it is not stored
+-- here. One row per (project, user).
+CREATE TABLE IF NOT EXISTS project_memberships
+(
+    project_id VARCHAR(255) NOT NULL,
+    user_id    VARCHAR(255) NOT NULL,
+    role       VARCHAR(32)  NOT NULL,
+    added_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
+    PRIMARY KEY (project_id, user_id),
+    KEY idx_project_memberships_role (role),
+    CONSTRAINT fk_project_memberships_project FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE,
+    CONSTRAINT fk_project_memberships_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE,
+    CONSTRAINT chk_project_memberships_role CHECK (role IN ('PI', 'CO_PI', 'ALLOCATION_MANAGER'))
+) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
diff --git a/internal/db/migrations/000004_allocations.up.sql b/internal/db/migrations/000004_allocations.up.sql
index 6144394e2..6488a5314 100644
--- a/internal/db/migrations/000004_allocations.up.sql
+++ b/internal/db/migrations/000004_allocations.up.sql
@@ -39,14 +39,19 @@ CREATE TABLE IF NOT EXISTS compute_allocations
 
 CREATE TABLE IF NOT EXISTS compute_allocation_resources
 (
-    id              VARCHAR(255) NOT NULL,
-    name            VARCHAR(255) NOT NULL,
-    resource_type   VARCHAR(64)  NOT NULL,
-    resource_amount BIGINT       NOT NULL DEFAULT 0,
-    created_at      TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
-    updated_at      TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
+    id                 VARCHAR(255) NOT NULL,
+    name               VARCHAR(255) NOT NULL,
+    resource_type      VARCHAR(64)  NOT NULL,
+    resource_amount    BIGINT       NOT NULL DEFAULT 0,
+    compute_cluster_id VARCHAR(255) NOT NULL,
+    created_at         TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
+    updated_at         TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
     PRIMARY KEY (id),
-    KEY idx_compute_allocation_resources_type (resource_type)
+    UNIQUE KEY uq_compute_allocation_resources_cluster_name (compute_cluster_id, name),
+    KEY idx_compute_allocation_resources_type (resource_type),
+    KEY idx_compute_allocation_resources_cluster (compute_cluster_id),
+    CONSTRAINT fk_compute_allocation_resources_cluster FOREIGN KEY (compute_cluster_id)
+        REFERENCES compute_clusters (id) ON DELETE RESTRICT
 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
 
 CREATE TABLE IF NOT EXISTS compute_allocation_resource_mappings
@@ -154,8 +159,8 @@ CREATE TABLE IF NOT EXISTS compute_allocation_usages
 (
     id                             VARCHAR(255) NOT NULL,
     compute_allocation_id          VARCHAR(255) NOT NULL,
-    used_raw_amount                BIGINT       NOT NULL DEFAULT 0,
-    used_su_amount                 BIGINT       NOT NULL DEFAULT 0,
+    used_raw_amount                DOUBLE       NOT NULL DEFAULT 0,
+    used_su_amount                 DOUBLE       NOT NULL DEFAULT 0,
     calculated_time                TIMESTAMP(6) NOT NULL,
     user_id                        VARCHAR(255) NOT NULL DEFAULT '',
     job_id                         VARCHAR(255) NOT NULL DEFAULT '',
diff --git a/internal/db/migrations/000005_audit.up.sql b/internal/db/migrations/000005_audit.up.sql
index 821984ac8..a214d120e 100644
--- a/internal/db/migrations/000005_audit.up.sql
+++ b/internal/db/migrations/000005_audit.up.sql
@@ -18,15 +18,26 @@
 SET NAMES utf8mb4;
 SET time_zone = '+00:00';
 
+-- entity_type records the kind of resource the row is about ("user", "role",
+-- "compute_cluster_user", "packet", etc.). source names the subsystem that
+-- produced the event.
 CREATE TABLE IF NOT EXISTS audit_events
 (
-    id         VARCHAR(255) NOT NULL,
-    event_type VARCHAR(128) NOT NULL,
-    event_time TIMESTAMP(6) NOT NULL,
-    entity_id  VARCHAR(255) NOT NULL,
-    details    TEXT         NOT NULL,
+    id             VARCHAR(255) NOT NULL,
+    event_type     VARCHAR(128) NOT NULL,
+    event_time     TIMESTAMP(6) NOT NULL,
+    entity_id      VARCHAR(255) NOT NULL,
+    entity_type    VARCHAR(64)  NOT NULL DEFAULT '',
+    details        TEXT         NOT NULL,
+    source         VARCHAR(64)  NOT NULL DEFAULT 'core',
+    trace_id       CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
+    span_id        CHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
+    parent_span_id CHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
     PRIMARY KEY (id),
     KEY idx_audit_events_entity (entity_id, event_time),
+    KEY idx_audit_events_entity_type (entity_type),
     KEY idx_audit_events_type (event_type, event_time),
-    KEY idx_audit_events_time (event_time)
+    KEY idx_audit_events_time (event_time),
+    KEY idx_audit_events_source (source),
+    KEY idx_audit_events_trace (trace_id)
 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
diff --git a/internal/db/migrations/000008_roles.down.sql b/internal/db/migrations/000006_authorization.down.sql
similarity index 95%
rename from internal/db/migrations/000008_roles.down.sql
rename to internal/db/migrations/000006_authorization.down.sql
index 369295853..098153a6d 100644
--- a/internal/db/migrations/000008_roles.down.sql
+++ b/internal/db/migrations/000006_authorization.down.sql
@@ -18,3 +18,4 @@
 DROP TABLE IF EXISTS user_roles;
 DROP TABLE IF EXISTS role_privileges;
 DROP TABLE IF EXISTS roles;
+DROP TABLE IF EXISTS user_privileges;
diff --git a/internal/db/migrations/000008_roles.up.sql b/internal/db/migrations/000006_authorization.up.sql
similarity index 74%
rename from internal/db/migrations/000008_roles.up.sql
rename to internal/db/migrations/000006_authorization.up.sql
index 298c3b35d..0bed464b6 100644
--- a/internal/db/migrations/000008_roles.up.sql
+++ b/internal/db/migrations/000006_authorization.up.sql
@@ -18,6 +18,24 @@
 SET NAMES utf8mb4;
 SET time_zone = '+00:00';
 
+-- Privileges held by a user. Only active grants live here; revoke is DELETE.
+-- The full grant/revoke history (who, when, why) is recorded in audit_events.
+CREATE TABLE IF NOT EXISTS user_privileges
+(
+    id          VARCHAR(255) NOT NULL,
+    user_id     VARCHAR(255) NOT NULL,
+    privilege   VARCHAR(64)  NOT NULL,
+    granted_by  VARCHAR(255) NULL,
+    granted_at  TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
+    reason      TEXT         NULL,
+    PRIMARY KEY (id),
+    UNIQUE KEY uq_user_privileges (user_id, privilege),
+    KEY idx_user_privileges_user (user_id),
+    KEY idx_user_privileges_priv (privilege),
+    CONSTRAINT fk_user_privileges_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE,
+    CONSTRAINT fk_user_privileges_granted_by FOREIGN KEY (granted_by) REFERENCES users (id) ON DELETE SET NULL
+) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
+
 -- Roles are named bundles of privileges. Granting a role to a user is
 -- equivalent to granting each of the role's privileges.
 CREATE TABLE IF NOT EXISTS roles
diff --git a/internal/db/migrations/000006_compute_allocation_resource_cluster.down.sql b/internal/db/migrations/000006_compute_allocation_resource_cluster.down.sql
deleted file mode 100644
index e2dfaea9d..000000000
--- a/internal/db/migrations/000006_compute_allocation_resource_cluster.down.sql
+++ /dev/null
@@ -1,22 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE compute_allocation_resources
-    DROP FOREIGN KEY fk_compute_allocation_resources_cluster,
-    DROP KEY uq_compute_allocation_resources_cluster_name,
-    DROP KEY idx_compute_allocation_resources_cluster,
-    DROP COLUMN compute_cluster_id;
diff --git a/internal/db/migrations/000006_compute_allocation_resource_cluster.up.sql b/internal/db/migrations/000006_compute_allocation_resource_cluster.up.sql
deleted file mode 100644
index f826a45ac..000000000
--- a/internal/db/migrations/000006_compute_allocation_resource_cluster.up.sql
+++ /dev/null
@@ -1,23 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE compute_allocation_resources
-    ADD COLUMN compute_cluster_id VARCHAR(255) NOT NULL,
-    ADD KEY idx_compute_allocation_resources_cluster (compute_cluster_id),
-    ADD UNIQUE KEY uq_compute_allocation_resources_cluster_name (compute_cluster_id, name),
-    ADD CONSTRAINT fk_compute_allocation_resources_cluster FOREIGN KEY (compute_cluster_id)
-        REFERENCES compute_clusters (id) ON DELETE RESTRICT;
diff --git a/internal/db/migrations/000007_user_privileges.down.sql b/internal/db/migrations/000007_user_privileges.down.sql
deleted file mode 100644
index 162b3d7bc..000000000
--- a/internal/db/migrations/000007_user_privileges.down.sql
+++ /dev/null
@@ -1,18 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-DROP TABLE IF EXISTS user_privileges;
diff --git a/internal/db/migrations/000007_user_privileges.up.sql b/internal/db/migrations/000007_user_privileges.up.sql
deleted file mode 100644
index 351bafb52..000000000
--- a/internal/db/migrations/000007_user_privileges.up.sql
+++ /dev/null
@@ -1,37 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-SET NAMES utf8mb4;
-SET time_zone = '+00:00';
-
--- Privileges held by a user. Only active grants live here; revoke is DELETE.
--- The full grant/revoke history (who, when, why) is recorded in audit_events.
-CREATE TABLE IF NOT EXISTS user_privileges
-(
-    id          VARCHAR(255) NOT NULL,
-    user_id     VARCHAR(255) NOT NULL,
-    privilege   VARCHAR(64)  NOT NULL,
-    granted_by  VARCHAR(255) NULL,
-    granted_at  TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
-    reason      TEXT         NULL,
-    PRIMARY KEY (id),
-    UNIQUE KEY uq_user_privileges (user_id, privilege),
-    KEY idx_user_privileges_user (user_id),
-    KEY idx_user_privileges_priv (privilege),
-    CONSTRAINT fk_user_privileges_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE,
-    CONSTRAINT fk_user_privileges_granted_by FOREIGN KEY (granted_by) REFERENCES users (id) ON DELETE SET NULL
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
diff --git a/internal/db/migrations/000009_update_allocation_usage_columns.down.sql b/internal/db/migrations/000009_update_allocation_usage_columns.down.sql
deleted file mode 100644
index d092d87a5..000000000
--- a/internal/db/migrations/000009_update_allocation_usage_columns.down.sql
+++ /dev/null
@@ -1,21 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
--- Revert ComputeAllocationUsage table columns to BIGINT
-ALTER TABLE compute_allocation_usages
-    MODIFY COLUMN used_raw_amount BIGINT NOT NULL DEFAULT 0,
-    MODIFY COLUMN used_su_amount BIGINT NOT NULL DEFAULT 0;
diff --git a/internal/db/migrations/000009_update_allocation_usage_columns.up.sql b/internal/db/migrations/000009_update_allocation_usage_columns.up.sql
deleted file mode 100644
index a820fb318..000000000
--- a/internal/db/migrations/000009_update_allocation_usage_columns.up.sql
+++ /dev/null
@@ -1,21 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
--- Update ComputeAllocationUsage table columns to match model data types
-ALTER TABLE compute_allocation_usages
-    MODIFY COLUMN used_raw_amount DOUBLE NOT NULL DEFAULT 0,
-    MODIFY COLUMN used_su_amount DOUBLE NOT NULL DEFAULT 0;
diff --git a/internal/db/migrations/000010_audit_trace_columns.down.sql b/internal/db/migrations/000010_audit_trace_columns.down.sql
deleted file mode 100644
index 5abb8640e..000000000
--- a/internal/db/migrations/000010_audit_trace_columns.down.sql
+++ /dev/null
@@ -1,22 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE audit_events
-    DROP KEY idx_audit_events_trace,
-    DROP COLUMN parent_span_id,
-    DROP COLUMN span_id,
-    DROP COLUMN trace_id;
diff --git a/internal/db/migrations/000010_audit_trace_columns.up.sql b/internal/db/migrations/000010_audit_trace_columns.up.sql
deleted file mode 100644
index 1316ee2f8..000000000
--- a/internal/db/migrations/000010_audit_trace_columns.up.sql
+++ /dev/null
@@ -1,22 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE audit_events
-    ADD COLUMN trace_id       CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
-    ADD COLUMN span_id        CHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
-    ADD COLUMN parent_span_id CHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
-    ADD KEY idx_audit_events_trace (trace_id);
diff --git a/internal/db/migrations/000011_audit_event_source.down.sql b/internal/db/migrations/000011_audit_event_source.down.sql
deleted file mode 100644
index 8bd376061..000000000
--- a/internal/db/migrations/000011_audit_event_source.down.sql
+++ /dev/null
@@ -1,20 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE audit_events
-    DROP KEY idx_audit_events_source,
-    DROP COLUMN source;
diff --git a/internal/db/migrations/000011_audit_event_source.up.sql b/internal/db/migrations/000011_audit_event_source.up.sql
deleted file mode 100644
index b55724e95..000000000
--- a/internal/db/migrations/000011_audit_event_source.up.sql
+++ /dev/null
@@ -1,20 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE audit_events
-    ADD COLUMN source VARCHAR(64) NOT NULL DEFAULT 'core',
-    ADD KEY idx_audit_events_source (source);
diff --git a/internal/db/migrations/000012_audit_events_entity_type.down.sql b/internal/db/migrations/000012_audit_events_entity_type.down.sql
deleted file mode 100644
index c192512d7..000000000
--- a/internal/db/migrations/000012_audit_events_entity_type.down.sql
+++ /dev/null
@@ -1,20 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE audit_events
-    DROP KEY idx_audit_events_entity_type,
-    DROP COLUMN entity_type;
diff --git a/internal/db/migrations/000012_audit_events_entity_type.up.sql b/internal/db/migrations/000012_audit_events_entity_type.up.sql
deleted file mode 100644
index 95e8c25e6..000000000
--- a/internal/db/migrations/000012_audit_events_entity_type.up.sql
+++ /dev/null
@@ -1,22 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
--- entity_type records the kind of resource the audit row is about
--- ("user", "role", "compute_cluster_user", "packet", etc.).
-ALTER TABLE audit_events
-    ADD COLUMN entity_type VARCHAR(64) NOT NULL DEFAULT '' AFTER entity_id,
-    ADD KEY idx_audit_events_entity_type (entity_type);
diff --git a/internal/db/migrations/000013_membership_role.down.sql b/internal/db/migrations/000013_membership_role.down.sql
deleted file mode 100644
index 28c87bac6..000000000
--- a/internal/db/migrations/000013_membership_role.down.sql
+++ /dev/null
@@ -1,20 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE compute_allocation_memberships
-    DROP KEY idx_compute_allocation_memberships_role,
-    DROP COLUMN role;
diff --git a/internal/db/migrations/000013_membership_role.up.sql b/internal/db/migrations/000013_membership_role.up.sql
deleted file mode 100644
index 3df06618f..000000000
--- a/internal/db/migrations/000013_membership_role.up.sql
+++ /dev/null
@@ -1,23 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
--- Persisted role of a user on a compute allocation membership. Values mirror
--- the AMIE-protocol role enum (PI / CO_PI / ALLOCATION_MANAGER / MEMBER);
--- non-AMIE callers default to MEMBER.
-ALTER TABLE compute_allocation_memberships
-    ADD COLUMN role VARCHAR(32) NOT NULL DEFAULT 'MEMBER' AFTER membership_status,
-    ADD KEY idx_compute_allocation_memberships_role (role);
diff --git a/internal/db/migrations/000014_project_memberships.down.sql b/internal/db/migrations/000014_project_memberships.down.sql
deleted file mode 100644
index 9c3e710a3..000000000
--- a/internal/db/migrations/000014_project_memberships.down.sql
+++ /dev/null
@@ -1,30 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE compute_allocation_memberships
-    ADD COLUMN role VARCHAR(32) NOT NULL DEFAULT 'MEMBER' AFTER membership_status,
-    ADD KEY idx_compute_allocation_memberships_role (role);
-
--- Project-level role applies to every allocation membership of the user
--- under that project.
-UPDATE compute_allocation_memberships m
-JOIN compute_allocations a   ON a.id = m.compute_allocation_id
-JOIN project_memberships pm  ON pm.project_id = a.project_id
-                            AND pm.user_id    = m.user_id
-SET m.role = pm.role;
-
-DROP TABLE project_memberships;
diff --git a/internal/db/migrations/000014_project_memberships.up.sql b/internal/db/migrations/000014_project_memberships.up.sql
deleted file mode 100644
index cd791373e..000000000
--- a/internal/db/migrations/000014_project_memberships.up.sql
+++ /dev/null
@@ -1,47 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
--- Project-level governance roles (PI / CO_PI / ALLOCATION_MANAGER). MEMBER
--- status is derived from compute_allocation_memberships, so it is not stored
--- here. One row per (project, user).
-CREATE TABLE project_memberships (
-    project_id VARCHAR(255) NOT NULL,
-    user_id    VARCHAR(255) NOT NULL,
-    role       VARCHAR(32) NOT NULL,
-    added_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
-    PRIMARY KEY (project_id, user_id),
-    KEY idx_project_memberships_role (role),
-    CONSTRAINT fk_project_memberships_project FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
-    CONSTRAINT fk_project_memberships_user    FOREIGN KEY (user_id)    REFERENCES users(id)    ON DELETE CASCADE,
-    CONSTRAINT chk_project_memberships_role   CHECK (role IN ('PI', 'CO_PI', 'ALLOCATION_MANAGER'))
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
-
--- Carry forward existing special roles that 000013 wrote onto
--- compute_allocation_memberships. The same user can appear on multiple
--- allocations of a project; collapse to one row per (project, user).
-INSERT INTO project_memberships (project_id, user_id, role, added_time)
-SELECT a.project_id, m.user_id,
-       MIN(m.role)       AS role,
-       MIN(m.start_time) AS added_time
-FROM compute_allocation_memberships m
-JOIN compute_allocations a ON a.id = m.compute_allocation_id
-WHERE m.role IN ('PI', 'CO_PI', 'ALLOCATION_MANAGER')
-GROUP BY a.project_id, m.user_id;
-
-ALTER TABLE compute_allocation_memberships
-    DROP KEY idx_compute_allocation_memberships_role,
-    DROP COLUMN role;
diff --git a/internal/db/migrations/000015_user_type.down.sql b/internal/db/migrations/000015_user_type.down.sql
deleted file mode 100644
index f0849b478..000000000
--- a/internal/db/migrations/000015_user_type.down.sql
+++ /dev/null
@@ -1,18 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE users DROP COLUMN type;
diff --git a/internal/db/migrations/000015_user_type.up.sql b/internal/db/migrations/000015_user_type.up.sql
deleted file mode 100644
index 43501e547..000000000
--- a/internal/db/migrations/000015_user_type.up.sql
+++ /dev/null
@@ -1,18 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements.  See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership.  The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License.  You may obtain a copy of the License at
---
---   http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied.  See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
-ALTER TABLE users ADD COLUMN type VARCHAR(32) NOT NULL DEFAULT 'CLUSTER_LOCAL';