move db migrations to different folder

This commit is contained in:
Vistaar Juneja 2023-08-04 10:43:44 +01:00
parent f04a695732
commit 09d2fee06e
3 changed files with 32 additions and 32 deletions

View File

@ -283,7 +283,6 @@ func setupPipelines(r chi.Router, pipelineCtrl *pipeline.Controller, executionCt
r.Get("/", handlerpipeline.HandleFind(pipelineCtrl)) r.Get("/", handlerpipeline.HandleFind(pipelineCtrl))
r.Patch("/", handlerpipeline.HandleUpdate(pipelineCtrl)) r.Patch("/", handlerpipeline.HandleUpdate(pipelineCtrl))
r.Delete("/", handlerpipeline.HandleDelete(pipelineCtrl)) r.Delete("/", handlerpipeline.HandleDelete(pipelineCtrl))
// TODO: setup executions here
setupExecutions(r, executionCtrl) setupExecutions(r, executionCtrl)
}) })
}) })
@ -291,7 +290,7 @@ func setupPipelines(r chi.Router, pipelineCtrl *pipeline.Controller, executionCt
func setupExecutions(r chi.Router, executionCtrl *execution.Controller) { func setupExecutions(r chi.Router, executionCtrl *execution.Controller) {
r.Route("/executions", func(r chi.Router) { r.Route("/executions", func(r chi.Router) {
r.Post("/")
}) })
} }

View File

@ -1,3 +1,34 @@
CREATE TABLE IF NOT EXISTS pipelines (
pipeline_id INTEGER PRIMARY KEY AUTOINCREMENT,
pipeline_description TEXT,
pipeline_parent_id INTEGER NOT NULL,
pipeline_uid TEXT NOT NULL,
pipeline_seq INTEGER NOT NULL DEFAULT 0,
pipeline_repo_id INTEGER,
pipeline_repo_type TEXT NOT NULL,
pipeline_repo_name TEXT,
pipeline_default_branch TEXT,
pipeline_config_path TEXT,
pipeline_created INTEGER,
pipeline_updated INTEGER,
pipeline_version INTEGER,
-- Ensure unique combination of UID and ParentID
UNIQUE (pipeline_parent_id, pipeline_uid),
-- Foreign key to spaces table
CONSTRAINT fk_pipeline_parent_id FOREIGN KEY (pipeline_parent_id)
REFERENCES spaces (space_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
-- Foreign key to repositories table
CONSTRAINT fk_pipeline_repo_id FOREIGN KEY (pipeline_repo_id)
REFERENCES repositories (repo_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS executions ( CREATE TABLE IF NOT EXISTS executions (
execution_id INTEGER PRIMARY KEY AUTOINCREMENT, execution_id INTEGER PRIMARY KEY AUTOINCREMENT,
execution_pipeline_id INTEGER NOT NULL, execution_pipeline_id INTEGER NOT NULL,

View File

@ -1,30 +0,0 @@
CREATE TABLE IF NOT EXISTS pipelines (
pipeline_id INTEGER PRIMARY KEY AUTOINCREMENT,
pipeline_description TEXT,
pipeline_parent_id INTEGER NOT NULL,
pipeline_uid TEXT NOT NULL,
pipeline_seq INTEGER NOT NULL DEFAULT 0,
pipeline_repo_id INTEGER,
pipeline_repo_type TEXT NOT NULL,
pipeline_repo_name TEXT,
pipeline_default_branch TEXT,
pipeline_config_path TEXT,
pipeline_created INTEGER,
pipeline_updated INTEGER,
pipeline_version INTEGER,
-- Ensure unique combination of UID and ParentID
UNIQUE (pipeline_parent_id, pipeline_uid),
-- Foreign key to spaces table
CONSTRAINT fk_pipeline_parent_id FOREIGN KEY (pipeline_parent_id)
REFERENCES spaces (space_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
-- Foreign key to repositories table
CONSTRAINT fk_pipeline_repo_id FOREIGN KEY (pipeline_repo_id)
REFERENCES repositories (repo_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
);