From e62950fada718c44d2ab43aae8e0713f55adafda Mon Sep 17 00:00:00 2001 From: hizmailovich Date: Tue, 13 Feb 2024 13:47:13 +0300 Subject: [PATCH] Tables renamed --- .../db/changelog/2024/003-naming.sql | 23 +++++++++++++++ src/main/resources/sql/insert-project.sql | 8 +++--- src/main/resources/sql/insert-ticket.sql | 10 +++---- .../resources/sql/select-project-by-id.sql | 2 +- .../sql/select-projects-by-user-email.sql | 6 ++-- .../sql/select-ticket-by-job-and-repo.sql | 2 +- .../sql/select-ticket-by-number-and-repo.sql | 2 +- src/test/resources/pre/sql/projects.sql | 28 +++++++++---------- 8 files changed, 52 insertions(+), 29 deletions(-) create mode 100644 src/main/resources/db/changelog/2024/003-naming.sql diff --git a/src/main/resources/db/changelog/2024/003-naming.sql b/src/main/resources/db/changelog/2024/003-naming.sql new file mode 100644 index 0000000..2d54255 --- /dev/null +++ b/src/main/resources/db/changelog/2024/003-naming.sql @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2023-2024 Tracehub.git + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to read + * the Software only. Permissions is hereby NOT GRANTED to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +--liquibase formatted sql + +--changeset hizmailovich:1 +ALTER TABLE projects.projects RENAME TO project; +ALTER TABLE projects.performers RENAME TO performer; +ALTER TABLE projects.tickets RENAME TO ticket; \ No newline at end of file diff --git a/src/main/resources/sql/insert-project.sql b/src/main/resources/sql/insert-project.sql index 6b681eb..f801038 100644 --- a/src/main/resources/sql/insert-project.sql +++ b/src/main/resources/sql/insert-project.sql @@ -15,10 +15,10 @@ * SOFTWARE. */ -INSERT INTO projects.projects (name, - location, - description, - active) +INSERT INTO projects.project (name, + location, + description, + active) VALUES (?, ?, ?, ?) RETURNING id, name, diff --git a/src/main/resources/sql/insert-ticket.sql b/src/main/resources/sql/insert-ticket.sql index 186a9ab..9203751 100644 --- a/src/main/resources/sql/insert-ticket.sql +++ b/src/main/resources/sql/insert-ticket.sql @@ -15,11 +15,11 @@ * SOFTWARE. */ -INSERT INTO projects.tickets (project, - number, - repo, - job, - status) +INSERT INTO projects.ticket (project, + number, + repo, + job, + status) VALUES (?, ?, ?, ?, ?) RETURNING id, project, diff --git a/src/main/resources/sql/select-project-by-id.sql b/src/main/resources/sql/select-project-by-id.sql index fcd473c..caffdac 100644 --- a/src/main/resources/sql/select-project-by-id.sql +++ b/src/main/resources/sql/select-project-by-id.sql @@ -20,5 +20,5 @@ SELECT id, location, description, active -FROM projects.projects +FROM projects.project WHERE id = ?; diff --git a/src/main/resources/sql/select-projects-by-user-email.sql b/src/main/resources/sql/select-projects-by-user-email.sql index 1ac4636..8c29a6b 100644 --- a/src/main/resources/sql/select-projects-by-user-email.sql +++ b/src/main/resources/sql/select-projects-by-user-email.sql @@ -20,6 +20,6 @@ SELECT p.id, p.location, p.description, p.active -FROM projects.projects p - INNER JOIN projects.performers on p.id = performers.project -WHERE performers.email = ?; +FROM projects.project p + INNER JOIN projects.performer on p.id = performer.project +WHERE performer.email = ?; diff --git a/src/main/resources/sql/select-ticket-by-job-and-repo.sql b/src/main/resources/sql/select-ticket-by-job-and-repo.sql index f567fcd..08f6a1f 100644 --- a/src/main/resources/sql/select-ticket-by-job-and-repo.sql +++ b/src/main/resources/sql/select-ticket-by-job-and-repo.sql @@ -21,5 +21,5 @@ SELECT id, repo, job, status -FROM projects.tickets +FROM projects.ticket WHERE job = ? AND repo = ?; diff --git a/src/main/resources/sql/select-ticket-by-number-and-repo.sql b/src/main/resources/sql/select-ticket-by-number-and-repo.sql index 7fc93fa..493d196 100644 --- a/src/main/resources/sql/select-ticket-by-number-and-repo.sql +++ b/src/main/resources/sql/select-ticket-by-number-and-repo.sql @@ -21,5 +21,5 @@ SELECT id, repo, job, status -FROM projects.tickets +FROM projects.ticket WHERE number = ? AND repo = ?; diff --git a/src/test/resources/pre/sql/projects.sql b/src/test/resources/pre/sql/projects.sql index 0108505..4c5aa0b 100644 --- a/src/test/resources/pre/sql/projects.sql +++ b/src/test/resources/pre/sql/projects.sql @@ -1,8 +1,8 @@ -INSERT INTO projects.projects (id, - name, - location, - description, - active) +INSERT INTO projects.project (id, + name, + location, + description, + active) VALUES ('74bb5ec8-0e6b-4618-bfa4-a0b76b7b312d', 'Test', 'github@user/test:master', @@ -10,19 +10,19 @@ VALUES ('74bb5ec8-0e6b-4618-bfa4-a0b76b7b312d', true) ON CONFLICT (id) DO NOTHING; -INSERT INTO projects.performers (email, - project, - permission) +INSERT INTO projects.performer (email, + project, + permission) VALUES ('user', '74bb5ec8-0e6b-4618-bfa4-a0b76b7b312d', 'READ'); -INSERT INTO projects.tickets(id, - project, - number, - repo, - job, - status) +INSERT INTO projects.ticket(id, + project, + number, + repo, + job, + status) VALUES ('04986038-6e38-4928-b12e-644c99f9cadc', '74bb5ec8-0e6b-4618-bfa4-a0b76b7b312d', 1,