This is an automated email from the ASF dual-hosted git repository. lahirujayathilake pushed a commit to branch migration-scripts in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
commit 589b6a4e83c070711402e4d47aff362f90ad8106 Author: lahiruj <[email protected]> AuthorDate: Fri May 22 13:10:16 2026 -0400 Consolidate core migrations into 4 domain-grouped files --- ...al_schema.down.sql => 000001_identity.down.sql} | 2 +- ...nitial_schema.up.sql => 000001_identity.up.sql} | 30 ++-- .../db/migrations/000002_compute_clusters.down.sql | 1 + .../db/migrations/000002_compute_clusters.up.sql | 18 ++ .../migrations/000003_compute_allocations.down.sql | 19 --- .../migrations/000003_compute_allocations.up.sql | 47 ----- ...dentities.down.sql => 000003_projects.down.sql} | 2 +- ...ocation_diffs.up.sql => 000003_projects.up.sql} | 28 +-- ...quests.down.sql => 000004_allocations.down.sql} | 8 + internal/db/migrations/000004_allocations.up.sql | 189 +++++++++++++++++++++ ...4_compute_allocation_resource_mappings.down.sql | 18 -- ...004_compute_allocation_resource_mappings.up.sql | 32 ---- ...0005_compute_allocation_resource_rates.down.sql | 18 -- ...000005_compute_allocation_resource_rates.up.sql | 32 ---- .../000006_compute_allocation_diffs.down.sql | 18 -- ...00007_compute_allocation_change_requests.up.sql | 49 ------ .../000008_compute_allocation_memberships.down.sql | 18 -- .../000008_compute_allocation_memberships.up.sql | 34 ---- .../000009_compute_allocation_usages.down.sql | 18 -- .../000009_compute_allocation_usages.up.sql | 36 ---- .../000010_compute_cluster_users.down.sql | 18 -- .../migrations/000010_compute_cluster_users.up.sql | 31 ---- ...location_membership_resource_overrides.down.sql | 21 --- ...allocation_membership_resource_overrides.up.sql | 36 ---- ...te_allocation_resource_mapping_amounts.down.sql | 20 --- ...pute_allocation_resource_mapping_amounts.up.sql | 20 --- ...n_membership_resource_override_amounts.down.sql | 20 --- ...ion_membership_resource_override_amounts.up.sql | 20 --- .../db/migrations/000014_users_status.down.sql | 20 --- internal/db/migrations/000014_users_status.up.sql | 20 --- .../db/migrations/000015_projects_status.down.sql | 20 --- .../db/migrations/000015_projects_status.up.sql | 20 --- .../db/migrations/000016_user_identities.up.sql | 38 ----- 33 files changed, 253 insertions(+), 668 deletions(-) diff --git a/internal/db/migrations/000001_initial_schema.down.sql b/internal/db/migrations/000001_identity.down.sql similarity index 95% rename from internal/db/migrations/000001_initial_schema.down.sql rename to internal/db/migrations/000001_identity.down.sql index 05fe180a5..67a59e0b9 100644 --- a/internal/db/migrations/000001_initial_schema.down.sql +++ b/internal/db/migrations/000001_identity.down.sql @@ -15,6 +15,6 @@ -- specific language governing permissions and limitations -- under the License. -DROP TABLE IF EXISTS projects; +DROP TABLE IF EXISTS user_identities; DROP TABLE IF EXISTS users; DROP TABLE IF EXISTS organizations; diff --git a/internal/db/migrations/000001_initial_schema.up.sql b/internal/db/migrations/000001_identity.up.sql similarity index 65% rename from internal/db/migrations/000001_initial_schema.up.sql rename to internal/db/migrations/000001_identity.up.sql index 2b8872db9..c7c142f30 100644 --- a/internal/db/migrations/000001_initial_schema.up.sql +++ b/internal/db/migrations/000001_identity.up.sql @@ -37,24 +37,34 @@ CREATE TABLE IF NOT EXISTS users last_name VARCHAR(255) NOT NULL, middle_name VARCHAR(255) NULL, email VARCHAR(255) NOT NULL, + status VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', 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), UNIQUE KEY uq_users_email (email), KEY idx_users_organization_id (organization_id), + KEY idx_users_status (status), CONSTRAINT fk_users_organization FOREIGN KEY (organization_id) REFERENCES organizations (id) ON DELETE RESTRICT ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; -CREATE TABLE IF NOT EXISTS projects +-- email captures the address the source IdP configured for this identity. +-- oidc_sub is nullable: not every external identity issues an OIDC subject +-- (AMIE binds by external_id only). UNIQUE permits multiple NULLs but blocks +-- collisions on real values across IdPs. +CREATE TABLE IF NOT EXISTS user_identities ( - id VARCHAR(255) NOT NULL, - originated_id VARCHAR(255) NOT NULL, - title VARCHAR(255) NOT NULL, - origination VARCHAR(255) NOT NULL, - project_pi_id VARCHAR(255) NOT NULL, - created_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + id VARCHAR(255) NOT NULL, + user_id VARCHAR(255) NOT NULL, + source VARCHAR(64) NOT NULL, + external_id VARCHAR(255) NOT NULL, + email VARCHAR(255) NULL DEFAULT NULL, + oidc_sub VARCHAR(255) NULL DEFAULT NULL, + metadata TEXT NULL DEFAULT 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_projects_originated_id (originated_id), - KEY idx_projects_pi (project_pi_id), - CONSTRAINT fk_projects_pi FOREIGN KEY (project_pi_id) REFERENCES users (id) ON DELETE RESTRICT + UNIQUE KEY uq_user_identities_source_external (source, external_id), + UNIQUE KEY uq_user_identities_oidc_sub (oidc_sub), + KEY idx_user_identities_user (user_id), + CONSTRAINT fk_user_identities_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000002_compute_clusters.down.sql b/internal/db/migrations/000002_compute_clusters.down.sql index 63df67edb..144a1e8b0 100644 --- a/internal/db/migrations/000002_compute_clusters.down.sql +++ b/internal/db/migrations/000002_compute_clusters.down.sql @@ -15,4 +15,5 @@ -- specific language governing permissions and limitations -- under the License. +DROP TABLE IF EXISTS compute_cluster_users; DROP TABLE IF EXISTS compute_clusters; diff --git a/internal/db/migrations/000002_compute_clusters.up.sql b/internal/db/migrations/000002_compute_clusters.up.sql index 098ab19f7..f0c268482 100644 --- a/internal/db/migrations/000002_compute_clusters.up.sql +++ b/internal/db/migrations/000002_compute_clusters.up.sql @@ -15,6 +15,9 @@ -- specific language governing permissions and limitations -- under the License. +SET NAMES utf8mb4; +SET time_zone = '+00:00'; + CREATE TABLE IF NOT EXISTS compute_clusters ( id VARCHAR(255) NOT NULL, @@ -24,3 +27,18 @@ CREATE TABLE IF NOT EXISTS compute_clusters PRIMARY KEY (id), UNIQUE KEY uq_compute_clusters_name (name) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS compute_cluster_users +( + id VARCHAR(255) NOT NULL, + compute_cluster_id VARCHAR(255) NOT NULL, + user_id VARCHAR(255) NOT NULL, + local_username 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), + UNIQUE KEY uq_compute_cluster_users_pair (compute_cluster_id, user_id), + KEY idx_compute_cluster_users_user (user_id), + CONSTRAINT fk_compute_cluster_users_cluster FOREIGN KEY (compute_cluster_id) REFERENCES compute_clusters (id) ON DELETE CASCADE, + CONSTRAINT fk_compute_cluster_users_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000003_compute_allocations.down.sql b/internal/db/migrations/000003_compute_allocations.down.sql deleted file mode 100644 index 71fc3aadf..000000000 --- a/internal/db/migrations/000003_compute_allocations.down.sql +++ /dev/null @@ -1,19 +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 compute_allocation_resources; -DROP TABLE IF EXISTS compute_allocations; diff --git a/internal/db/migrations/000003_compute_allocations.up.sql b/internal/db/migrations/000003_compute_allocations.up.sql deleted file mode 100644 index 68144ad61..000000000 --- a/internal/db/migrations/000003_compute_allocations.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. - -CREATE TABLE IF NOT EXISTS compute_allocations -( - id VARCHAR(255) NOT NULL, - project_id VARCHAR(255) NOT NULL, - name VARCHAR(255) NOT NULL, - status VARCHAR(64) NOT NULL, - compute_cluster_id VARCHAR(255) NOT NULL, - initial_su_amount BIGINT NOT NULL DEFAULT 0, - start_time TIMESTAMP(6) NOT NULL, - end_time TIMESTAMP(6) 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_allocations_project (project_id), - KEY idx_compute_allocations_cluster (compute_cluster_id), - CONSTRAINT fk_compute_allocations_project FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE RESTRICT, - CONSTRAINT fk_compute_allocations_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_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), - PRIMARY KEY (id), - KEY idx_compute_allocation_resources_type (resource_type) -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000016_user_identities.down.sql b/internal/db/migrations/000003_projects.down.sql similarity index 95% rename from internal/db/migrations/000016_user_identities.down.sql rename to internal/db/migrations/000003_projects.down.sql index 08b342405..fb20b72d0 100644 --- a/internal/db/migrations/000016_user_identities.down.sql +++ b/internal/db/migrations/000003_projects.down.sql @@ -15,4 +15,4 @@ -- specific language governing permissions and limitations -- under the License. -DROP TABLE IF EXISTS user_identities; +DROP TABLE IF EXISTS projects; diff --git a/internal/db/migrations/000006_compute_allocation_diffs.up.sql b/internal/db/migrations/000003_projects.up.sql similarity index 53% rename from internal/db/migrations/000006_compute_allocation_diffs.up.sql rename to internal/db/migrations/000003_projects.up.sql index f702cb8c1..8dd9cb1a8 100644 --- a/internal/db/migrations/000006_compute_allocation_diffs.up.sql +++ b/internal/db/migrations/000003_projects.up.sql @@ -15,19 +15,21 @@ -- specific language governing permissions and limitations -- under the License. -CREATE TABLE IF NOT EXISTS compute_allocation_diffs +SET NAMES utf8mb4; +SET time_zone = '+00:00'; + +CREATE TABLE IF NOT EXISTS projects ( - id VARCHAR(255) NOT NULL, - compute_allocation_id VARCHAR(255) NOT NULL, - diff_type VARCHAR(64) NOT NULL, - new_su_amount BIGINT NOT NULL DEFAULT 0, - status VARCHAR(64) NOT NULL, - timestamp TIMESTAMP(6) NOT NULL, - description TEXT NOT NULL, - created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + id VARCHAR(255) NOT NULL, + originated_id VARCHAR(255) NOT NULL, + title VARCHAR(255) NOT NULL, + origination VARCHAR(255) NOT NULL, + project_pi_id VARCHAR(255) NOT NULL, + status VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', + created_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), PRIMARY KEY (id), - KEY idx_compute_allocation_diffs_allocation (compute_allocation_id, timestamp), - KEY idx_compute_allocation_diffs_type (diff_type), - CONSTRAINT fk_compute_allocation_diffs_allocation FOREIGN KEY (compute_allocation_id) - REFERENCES compute_allocations (id) ON DELETE CASCADE + KEY idx_projects_originated_id (originated_id), + KEY idx_projects_pi (project_pi_id), + 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; diff --git a/internal/db/migrations/000007_compute_allocation_change_requests.down.sql b/internal/db/migrations/000004_allocations.down.sql similarity index 68% rename from internal/db/migrations/000007_compute_allocation_change_requests.down.sql rename to internal/db/migrations/000004_allocations.down.sql index 8140a01cb..a8e4a1cd0 100644 --- a/internal/db/migrations/000007_compute_allocation_change_requests.down.sql +++ b/internal/db/migrations/000004_allocations.down.sql @@ -15,5 +15,13 @@ -- specific language governing permissions and limitations -- under the License. +DROP TABLE IF EXISTS compute_allocation_membership_resource_overrides; +DROP TABLE IF EXISTS compute_allocation_usages; +DROP TABLE IF EXISTS compute_allocation_memberships; DROP TABLE IF EXISTS compute_allocation_change_request_events; DROP TABLE IF EXISTS compute_allocation_change_requests; +DROP TABLE IF EXISTS compute_allocation_diffs; +DROP TABLE IF EXISTS compute_allocation_resource_rates; +DROP TABLE IF EXISTS compute_allocation_resource_mappings; +DROP TABLE IF EXISTS compute_allocation_resources; +DROP TABLE IF EXISTS compute_allocations; diff --git a/internal/db/migrations/000004_allocations.up.sql b/internal/db/migrations/000004_allocations.up.sql new file mode 100644 index 000000000..8624ed724 --- /dev/null +++ b/internal/db/migrations/000004_allocations.up.sql @@ -0,0 +1,189 @@ +-- 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'; + +CREATE TABLE IF NOT EXISTS compute_allocations +( + id VARCHAR(255) NOT NULL, + project_id VARCHAR(255) NOT NULL, + name VARCHAR(255) NOT NULL, + status VARCHAR(64) NOT NULL, + compute_cluster_id VARCHAR(255) NOT NULL, + initial_su_amount BIGINT NOT NULL DEFAULT 0, + start_time TIMESTAMP(6) NOT NULL, + end_time TIMESTAMP(6) 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_allocations_project (project_id), + KEY idx_compute_allocations_cluster (compute_cluster_id), + CONSTRAINT fk_compute_allocations_project FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE RESTRICT, + CONSTRAINT fk_compute_allocations_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_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), + PRIMARY KEY (id), + KEY idx_compute_allocation_resources_type (resource_type) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS compute_allocation_resource_mappings +( + id VARCHAR(255) NOT NULL, + compute_allocation_id VARCHAR(255) NOT NULL, + compute_allocation_resource_id VARCHAR(255) NOT NULL, + resource_amount BIGINT NOT NULL DEFAULT 0, + resource_time BIGINT NOT NULL DEFAULT 0, + created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (id), + UNIQUE KEY uq_carm_pair (compute_allocation_id, compute_allocation_resource_id), + KEY idx_carm_allocation (compute_allocation_id), + KEY idx_carm_resource (compute_allocation_resource_id), + CONSTRAINT fk_carm_allocation FOREIGN KEY (compute_allocation_id) + REFERENCES compute_allocations (id) ON DELETE CASCADE, + CONSTRAINT fk_carm_resource FOREIGN KEY (compute_allocation_resource_id) + REFERENCES compute_allocation_resources (id) ON DELETE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS compute_allocation_resource_rates +( + id VARCHAR(255) NOT NULL, + compute_allocation_resource_id VARCHAR(255) NOT NULL, + rate DOUBLE NOT NULL DEFAULT 0, + start_time TIMESTAMP(6) NOT NULL, + end_time TIMESTAMP(6) 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_carr_rates_resource (compute_allocation_resource_id), + KEY idx_carr_rates_window (compute_allocation_resource_id, start_time, end_time), + CONSTRAINT fk_carr_rates_resource FOREIGN KEY (compute_allocation_resource_id) + REFERENCES compute_allocation_resources (id) ON DELETE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS compute_allocation_diffs +( + id VARCHAR(255) NOT NULL, + compute_allocation_id VARCHAR(255) NOT NULL, + diff_type VARCHAR(64) NOT NULL, + new_su_amount BIGINT NOT NULL DEFAULT 0, + status VARCHAR(64) NOT NULL, + timestamp TIMESTAMP(6) NOT NULL, + description TEXT NOT NULL, + created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (id), + KEY idx_compute_allocation_diffs_allocation (compute_allocation_id, timestamp), + KEY idx_compute_allocation_diffs_type (diff_type), + CONSTRAINT fk_compute_allocation_diffs_allocation FOREIGN KEY (compute_allocation_id) + REFERENCES compute_allocations (id) ON DELETE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS compute_allocation_change_requests +( + id VARCHAR(255) NOT NULL, + compute_allocation_id VARCHAR(255) NOT NULL, + requested_su_amount BIGINT NOT NULL DEFAULT 0, + requested_status VARCHAR(64) NOT NULL, + reason TEXT NOT NULL, + change_status VARCHAR(64) NOT NULL, + requester_id VARCHAR(255) NOT NULL, + approver_id VARCHAR(255) NOT NULL DEFAULT '', + timestamp TIMESTAMP(6) NOT NULL, + created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (id), + KEY idx_compute_allocation_change_requests_allocation (compute_allocation_id, timestamp), + KEY idx_compute_allocation_change_requests_status (change_status), + KEY idx_compute_allocation_change_requests_requester (requester_id), + CONSTRAINT fk_compute_allocation_change_requests_allocation FOREIGN KEY (compute_allocation_id) + REFERENCES compute_allocations (id) ON DELETE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS compute_allocation_change_request_events +( + id VARCHAR(255) NOT NULL, + compute_allocation_change_request_id VARCHAR(255) NOT NULL, + event_type VARCHAR(64) NOT NULL, + description TEXT NOT NULL, + timestamp TIMESTAMP(6) NOT NULL, + created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (id), + KEY idx_compute_allocation_change_request_events_request (compute_allocation_change_request_id, timestamp), + KEY idx_compute_allocation_change_request_events_type (event_type) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS compute_allocation_memberships +( + id VARCHAR(255) NOT NULL, + compute_allocation_id VARCHAR(255) NOT NULL, + user_id VARCHAR(255) NOT NULL, + start_time TIMESTAMP(6) NOT NULL, + end_time TIMESTAMP(6) NOT NULL, + membership_status VARCHAR(64) NOT NULL, + created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (id), + UNIQUE KEY uq_compute_allocation_memberships_allocation_user (compute_allocation_id, user_id), + KEY idx_compute_allocation_memberships_user (user_id), + KEY idx_compute_allocation_memberships_status (membership_status), + CONSTRAINT fk_compute_allocation_memberships_allocation FOREIGN KEY (compute_allocation_id) + REFERENCES compute_allocations (id) ON DELETE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +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, + calculated_time TIMESTAMP(6) NOT NULL, + user_id VARCHAR(255) NOT NULL DEFAULT '', + job_id VARCHAR(255) NOT NULL DEFAULT '', + compute_allocation_resource_id VARCHAR(255) NOT NULL DEFAULT '', + created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), + PRIMARY KEY (id), + KEY idx_compute_allocation_usages_allocation (compute_allocation_id, calculated_time), + KEY idx_compute_allocation_usages_user (user_id), + KEY idx_compute_allocation_usages_job (job_id), + KEY idx_compute_allocation_usages_resource (compute_allocation_resource_id), + CONSTRAINT fk_compute_allocation_usages_allocation FOREIGN KEY (compute_allocation_id) + REFERENCES compute_allocations (id) ON DELETE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS compute_allocation_membership_resource_overrides +( + id VARCHAR(255) NOT NULL, + compute_allocation_membership_id VARCHAR(255) NOT NULL, + compute_allocation_resource_id VARCHAR(255) NOT NULL, + override_resource_amount BIGINT NOT NULL DEFAULT 0, + override_resource_time 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), + PRIMARY KEY (id), + UNIQUE KEY uq_camro_membership_resource (compute_allocation_membership_id, compute_allocation_resource_id), + KEY idx_camro_resource (compute_allocation_resource_id), + CONSTRAINT fk_camro_membership FOREIGN KEY (compute_allocation_membership_id) + REFERENCES compute_allocation_memberships (id) ON DELETE CASCADE, + CONSTRAINT fk_camro_resource FOREIGN KEY (compute_allocation_resource_id) + REFERENCES compute_allocation_resources (id) ON DELETE CASCADE +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000004_compute_allocation_resource_mappings.down.sql b/internal/db/migrations/000004_compute_allocation_resource_mappings.down.sql deleted file mode 100644 index cfceaf2fd..000000000 --- a/internal/db/migrations/000004_compute_allocation_resource_mappings.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 compute_allocation_resource_mappings; diff --git a/internal/db/migrations/000004_compute_allocation_resource_mappings.up.sql b/internal/db/migrations/000004_compute_allocation_resource_mappings.up.sql deleted file mode 100644 index 877cc0ba7..000000000 --- a/internal/db/migrations/000004_compute_allocation_resource_mappings.up.sql +++ /dev/null @@ -1,32 +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. - -CREATE TABLE IF NOT EXISTS compute_allocation_resource_mappings -( - id VARCHAR(255) NOT NULL, - compute_allocation_id VARCHAR(255) NOT NULL, - compute_allocation_resource_id VARCHAR(255) NOT NULL, - created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), - PRIMARY KEY (id), - UNIQUE KEY uq_carm_pair (compute_allocation_id, compute_allocation_resource_id), - KEY idx_carm_allocation (compute_allocation_id), - KEY idx_carm_resource (compute_allocation_resource_id), - CONSTRAINT fk_carm_allocation FOREIGN KEY (compute_allocation_id) - REFERENCES compute_allocations (id) ON DELETE CASCADE, - CONSTRAINT fk_carm_resource FOREIGN KEY (compute_allocation_resource_id) - REFERENCES compute_allocation_resources (id) ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000005_compute_allocation_resource_rates.down.sql b/internal/db/migrations/000005_compute_allocation_resource_rates.down.sql deleted file mode 100644 index b6938f6ea..000000000 --- a/internal/db/migrations/000005_compute_allocation_resource_rates.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 compute_allocation_resource_rates; diff --git a/internal/db/migrations/000005_compute_allocation_resource_rates.up.sql b/internal/db/migrations/000005_compute_allocation_resource_rates.up.sql deleted file mode 100644 index e49346c5e..000000000 --- a/internal/db/migrations/000005_compute_allocation_resource_rates.up.sql +++ /dev/null @@ -1,32 +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. - -CREATE TABLE IF NOT EXISTS compute_allocation_resource_rates -( - id VARCHAR(255) NOT NULL, - compute_allocation_resource_id VARCHAR(255) NOT NULL, - rate DOUBLE NOT NULL DEFAULT 0, - start_time TIMESTAMP(6) NOT NULL, - end_time TIMESTAMP(6) 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_carr_rates_resource (compute_allocation_resource_id), - KEY idx_carr_rates_window (compute_allocation_resource_id, start_time, end_time), - CONSTRAINT fk_carr_rates_resource FOREIGN KEY (compute_allocation_resource_id) - REFERENCES compute_allocation_resources (id) ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000006_compute_allocation_diffs.down.sql b/internal/db/migrations/000006_compute_allocation_diffs.down.sql deleted file mode 100644 index b0a79aecf..000000000 --- a/internal/db/migrations/000006_compute_allocation_diffs.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 compute_allocation_diffs; diff --git a/internal/db/migrations/000007_compute_allocation_change_requests.up.sql b/internal/db/migrations/000007_compute_allocation_change_requests.up.sql deleted file mode 100644 index aa04a8571..000000000 --- a/internal/db/migrations/000007_compute_allocation_change_requests.up.sql +++ /dev/null @@ -1,49 +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. - -CREATE TABLE IF NOT EXISTS compute_allocation_change_requests -( - id VARCHAR(255) NOT NULL, - compute_allocation_id VARCHAR(255) NOT NULL, - requested_su_amount BIGINT NOT NULL DEFAULT 0, - requested_status VARCHAR(64) NOT NULL, - reason TEXT NOT NULL, - change_status VARCHAR(64) NOT NULL, - requester_id VARCHAR(255) NOT NULL, - approver_id VARCHAR(255) NOT NULL DEFAULT '', - timestamp TIMESTAMP(6) NOT NULL, - created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), - PRIMARY KEY (id), - KEY idx_compute_allocation_change_requests_allocation (compute_allocation_id, timestamp), - KEY idx_compute_allocation_change_requests_status (change_status), - KEY idx_compute_allocation_change_requests_requester (requester_id), - CONSTRAINT fk_compute_allocation_change_requests_allocation FOREIGN KEY (compute_allocation_id) - REFERENCES compute_allocations (id) ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; - -CREATE TABLE IF NOT EXISTS compute_allocation_change_request_events -( - id VARCHAR(255) NOT NULL, - compute_allocation_change_request_id VARCHAR(255) NOT NULL, - event_type VARCHAR(64) NOT NULL, - description TEXT NOT NULL, - timestamp TIMESTAMP(6) NOT NULL, - created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), - PRIMARY KEY (id), - KEY idx_compute_allocation_change_request_events_request (compute_allocation_change_request_id, timestamp), - KEY idx_compute_allocation_change_request_events_type (event_type) -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000008_compute_allocation_memberships.down.sql b/internal/db/migrations/000008_compute_allocation_memberships.down.sql deleted file mode 100644 index 731073898..000000000 --- a/internal/db/migrations/000008_compute_allocation_memberships.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 compute_allocation_memberships; diff --git a/internal/db/migrations/000008_compute_allocation_memberships.up.sql b/internal/db/migrations/000008_compute_allocation_memberships.up.sql deleted file mode 100644 index 17f753566..000000000 --- a/internal/db/migrations/000008_compute_allocation_memberships.up.sql +++ /dev/null @@ -1,34 +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. - -CREATE TABLE IF NOT EXISTS compute_allocation_memberships -( - id VARCHAR(255) NOT NULL, - compute_allocation_id VARCHAR(255) NOT NULL, - user_id VARCHAR(255) NOT NULL, - allocation_amount BIGINT NOT NULL DEFAULT 0, - start_time TIMESTAMP(6) NOT NULL, - end_time TIMESTAMP(6) NOT NULL, - membership_status VARCHAR(64) NOT NULL, - created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), - PRIMARY KEY (id), - UNIQUE KEY uq_compute_allocation_memberships_allocation_user (compute_allocation_id, user_id), - KEY idx_compute_allocation_memberships_user (user_id), - KEY idx_compute_allocation_memberships_status (membership_status), - CONSTRAINT fk_compute_allocation_memberships_allocation FOREIGN KEY (compute_allocation_id) - REFERENCES compute_allocations (id) ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000009_compute_allocation_usages.down.sql b/internal/db/migrations/000009_compute_allocation_usages.down.sql deleted file mode 100644 index 8e089a51d..000000000 --- a/internal/db/migrations/000009_compute_allocation_usages.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 compute_allocation_usages; diff --git a/internal/db/migrations/000009_compute_allocation_usages.up.sql b/internal/db/migrations/000009_compute_allocation_usages.up.sql deleted file mode 100644 index d1e875c4c..000000000 --- a/internal/db/migrations/000009_compute_allocation_usages.up.sql +++ /dev/null @@ -1,36 +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. - -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, - calculated_time TIMESTAMP(6) NOT NULL, - user_id VARCHAR(255) NOT NULL DEFAULT '', - job_id VARCHAR(255) NOT NULL DEFAULT '', - compute_allocation_resource_id VARCHAR(255) NOT NULL DEFAULT '', - created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), - PRIMARY KEY (id), - KEY idx_compute_allocation_usages_allocation (compute_allocation_id, calculated_time), - KEY idx_compute_allocation_usages_user (user_id), - KEY idx_compute_allocation_usages_job (job_id), - KEY idx_compute_allocation_usages_resource (compute_allocation_resource_id), - CONSTRAINT fk_compute_allocation_usages_allocation FOREIGN KEY (compute_allocation_id) - REFERENCES compute_allocations (id) ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000010_compute_cluster_users.down.sql b/internal/db/migrations/000010_compute_cluster_users.down.sql deleted file mode 100644 index c207cd7c1..000000000 --- a/internal/db/migrations/000010_compute_cluster_users.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 compute_cluster_users; diff --git a/internal/db/migrations/000010_compute_cluster_users.up.sql b/internal/db/migrations/000010_compute_cluster_users.up.sql deleted file mode 100644 index 284536208..000000000 --- a/internal/db/migrations/000010_compute_cluster_users.up.sql +++ /dev/null @@ -1,31 +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. - -CREATE TABLE IF NOT EXISTS compute_cluster_users -( - id VARCHAR(255) NOT NULL, - compute_cluster_id VARCHAR(255) NOT NULL, - user_id VARCHAR(255) NOT NULL, - local_username 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), - UNIQUE KEY uq_compute_cluster_users_pair (compute_cluster_id, user_id), - KEY idx_compute_cluster_users_user (user_id), - CONSTRAINT fk_compute_cluster_users_cluster FOREIGN KEY (compute_cluster_id) REFERENCES compute_clusters (id) ON DELETE CASCADE, - CONSTRAINT fk_compute_cluster_users_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000011_compute_allocation_membership_resource_overrides.down.sql b/internal/db/migrations/000011_compute_allocation_membership_resource_overrides.down.sql deleted file mode 100644 index e07d3db11..000000000 --- a/internal/db/migrations/000011_compute_allocation_membership_resource_overrides.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. - -DROP TABLE IF EXISTS compute_allocation_membership_resource_overrides; - -ALTER TABLE compute_allocation_memberships - ADD COLUMN allocation_amount BIGINT NOT NULL DEFAULT 0 AFTER user_id; diff --git a/internal/db/migrations/000011_compute_allocation_membership_resource_overrides.up.sql b/internal/db/migrations/000011_compute_allocation_membership_resource_overrides.up.sql deleted file mode 100644 index 946bbb029..000000000 --- a/internal/db/migrations/000011_compute_allocation_membership_resource_overrides.up.sql +++ /dev/null @@ -1,36 +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 COLUMN allocation_amount; - -CREATE TABLE IF NOT EXISTS compute_allocation_membership_resource_overrides -( - id VARCHAR(255) NOT NULL, - compute_allocation_membership_id VARCHAR(255) NOT NULL, - compute_allocation_resource_id VARCHAR(255) NOT NULL, - overridden_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), - PRIMARY KEY (id), - UNIQUE KEY uq_camro_membership_resource (compute_allocation_membership_id, compute_allocation_resource_id), - KEY idx_camro_resource (compute_allocation_resource_id), - CONSTRAINT fk_camro_membership FOREIGN KEY (compute_allocation_membership_id) - REFERENCES compute_allocation_memberships (id) ON DELETE CASCADE, - CONSTRAINT fk_camro_resource FOREIGN KEY (compute_allocation_resource_id) - REFERENCES compute_allocation_resources (id) ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; diff --git a/internal/db/migrations/000012_compute_allocation_resource_mapping_amounts.down.sql b/internal/db/migrations/000012_compute_allocation_resource_mapping_amounts.down.sql deleted file mode 100644 index b792b9027..000000000 --- a/internal/db/migrations/000012_compute_allocation_resource_mapping_amounts.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_resource_mappings - DROP COLUMN resource_time, - DROP COLUMN resource_amount; diff --git a/internal/db/migrations/000012_compute_allocation_resource_mapping_amounts.up.sql b/internal/db/migrations/000012_compute_allocation_resource_mapping_amounts.up.sql deleted file mode 100644 index 120491635..000000000 --- a/internal/db/migrations/000012_compute_allocation_resource_mapping_amounts.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 compute_allocation_resource_mappings - ADD COLUMN resource_amount BIGINT NOT NULL DEFAULT 0 AFTER compute_allocation_resource_id, - ADD COLUMN resource_time BIGINT NOT NULL DEFAULT 0 AFTER resource_amount; diff --git a/internal/db/migrations/000013_compute_allocation_membership_resource_override_amounts.down.sql b/internal/db/migrations/000013_compute_allocation_membership_resource_override_amounts.down.sql deleted file mode 100644 index c937d1aca..000000000 --- a/internal/db/migrations/000013_compute_allocation_membership_resource_override_amounts.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_membership_resource_overrides - DROP COLUMN override_resource_time, - CHANGE COLUMN override_resource_amount overridden_resource_amount BIGINT NOT NULL DEFAULT 0; diff --git a/internal/db/migrations/000013_compute_allocation_membership_resource_override_amounts.up.sql b/internal/db/migrations/000013_compute_allocation_membership_resource_override_amounts.up.sql deleted file mode 100644 index bc18ef857..000000000 --- a/internal/db/migrations/000013_compute_allocation_membership_resource_override_amounts.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 compute_allocation_membership_resource_overrides - CHANGE COLUMN overridden_resource_amount override_resource_amount BIGINT NOT NULL DEFAULT 0, - ADD COLUMN override_resource_time BIGINT NOT NULL DEFAULT 0 AFTER override_resource_amount; diff --git a/internal/db/migrations/000014_users_status.down.sql b/internal/db/migrations/000014_users_status.down.sql deleted file mode 100644 index 8c5d8445d..000000000 --- a/internal/db/migrations/000014_users_status.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 users - DROP KEY idx_users_status, - DROP COLUMN status; diff --git a/internal/db/migrations/000014_users_status.up.sql b/internal/db/migrations/000014_users_status.up.sql deleted file mode 100644 index 5b88416a6..000000000 --- a/internal/db/migrations/000014_users_status.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 users - ADD COLUMN status VARCHAR(32) NOT NULL DEFAULT 'ACTIVE' AFTER email, - ADD KEY idx_users_status (status); diff --git a/internal/db/migrations/000015_projects_status.down.sql b/internal/db/migrations/000015_projects_status.down.sql deleted file mode 100644 index 136999f6f..000000000 --- a/internal/db/migrations/000015_projects_status.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 projects - DROP KEY idx_projects_status, - DROP COLUMN status; diff --git a/internal/db/migrations/000015_projects_status.up.sql b/internal/db/migrations/000015_projects_status.up.sql deleted file mode 100644 index 1de30ed61..000000000 --- a/internal/db/migrations/000015_projects_status.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 projects - ADD COLUMN status VARCHAR(32) NOT NULL DEFAULT 'ACTIVE' AFTER project_pi_id, - ADD KEY idx_projects_status (status); diff --git a/internal/db/migrations/000016_user_identities.up.sql b/internal/db/migrations/000016_user_identities.up.sql deleted file mode 100644 index 249468c89..000000000 --- a/internal/db/migrations/000016_user_identities.up.sql +++ /dev/null @@ -1,38 +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. - --- email captures the address the source IdP configured for this identity. --- oidc_sub is nullable: not every external identity issues an OIDC subject --- (AMIE binds by external_id only). UNIQUE permits multiple NULLs but blocks --- collisions on real values across IdPs. -CREATE TABLE IF NOT EXISTS user_identities -( - id VARCHAR(255) NOT NULL, - user_id VARCHAR(255) NOT NULL, - source VARCHAR(64) NOT NULL, - external_id VARCHAR(255) NOT NULL, - email VARCHAR(255) NULL DEFAULT NULL, - oidc_sub VARCHAR(255) NULL DEFAULT NULL, - metadata TEXT NULL DEFAULT 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), - UNIQUE KEY uq_user_identities_source_external (source, external_id), - UNIQUE KEY uq_user_identities_oidc_sub (oidc_sub), - KEY idx_user_identities_user (user_id), - CONSTRAINT fk_user_identities_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
