Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/datastore/mysql/ensurer/indexes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,10 @@ CREATE INDEX event_key_name_project_id_created_at_desc ON Event (EventKey, Name,
-- index on `ProjectId` ASC and `EnvIds` ASC
ALTER TABLE Piped ADD COLUMN EnvIds JSON GENERATED ALWAYS AS (IFNULL(data ->> "$.env_ids", '[]')) VIRTUAL NOT NULL;
CREATE INDEX piped_project_id_env_ids_asc ON Piped (ProjectId, (CAST(EnvIds AS CHAR(36) ARRAY)));

--
-- DeploymentChain table indexes
--

-- index on `ProjectId` ASC and `UpdatedAt` DESC
CREATE INDEX deploymentchain_project_id_updated_at_desc ON DeploymentChain (ProjectId, UpdatedAt DESC);
13 changes: 13 additions & 0 deletions pkg/datastore/mysql/ensurer/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,16 @@ CREATE TABLE IF NOT EXISTS Event (
CreatedAt INT(11) GENERATED ALWAYS AS (data->>"$.created_at") STORED NOT NULL,
UpdatedAt INT(11) GENERATED ALWAYS AS (data->>"$.updated_at") STORED NOT NULL
) ENGINE=InnoDB;

--
-- DeploymentChain table
--

CREATE TABLE IF NOT EXISTS DeploymentChain (
Id BINARY(16) PRIMARY KEY,
Data JSON NOT NULL,
ProjectId VARCHAR(50) GENERATED ALWAYS AS (data->>"$.project_id") STORED NOT NULL,
Extra VARCHAR(100) GENERATED ALWAYS AS (data->>"$._extra") STORED,
CreatedAt INT(11) GENERATED ALWAYS AS (data->>"$.created_at") STORED NOT NULL,
UpdatedAt INT(11) GENERATED ALWAYS AS (data->>"$.updated_at") STORED NOT NULL
) ENGINE=InnoDB;