Skip to content

Commit

Permalink
feat: update DB schema name and add DB scripts (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeLyttle authored Nov 29, 2024
1 parent 2b8aa06 commit 4f63de5
Show file tree
Hide file tree
Showing 9 changed files with 7,554 additions and 9 deletions.
4 changes: 3 additions & 1 deletion charts/app/templates/backend/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
- name: FLYWAY_BASELINE_ON_MIGRATE
value: "true"
- name: FLYWAY_DEFAULT_SCHEMA
value: "USERS"
value: "codes"
- name: FLYWAY_CONNECT_RETRIES
value: "10"
resources:
Expand All @@ -63,6 +63,8 @@ spec:
env:
- name: LOG_LEVEL
value: info
- name: DB_SCHEMA
value: codes
ports:
- name: http
containerPort: {{ .Values.backend.service.targetPort }}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
FLYWAY_USER: *POSTGRES_USER
FLYWAY_PASSWORD: *POSTGRES_PASSWORD
FLYWAY_BASELINE_ON_MIGRATE: true
FLYWAY_DEFAULT_SCHEMA: users
FLYWAY_DEFAULT_SCHEMA: codes
depends_on:
database:
condition: service_healthy
Expand All @@ -43,7 +43,7 @@ services:
image: schemaspy/schemaspy:6.2.4
profiles: ["schemaspy"]
container_name: schemaspy
command: -t pgsql11 -db postgres -host database -port 5432 -u postgres -p default -schemas users
command: -t pgsql11 -db postgres -host database -port 5432 -u postgres -p default -schemas codes
depends_on:
migrations:
condition: service_completed_successfully
Expand Down
10 changes: 5 additions & 5 deletions migrations/sql/V1.0.0__init.sql
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
CREATE SCHEMA IF NOT EXISTS USERS;
CREATE SCHEMA IF NOT EXISTS codes;

CREATE SEQUENCE IF NOT EXISTS USERS."USER_SEQ"
CREATE SEQUENCE IF NOT EXISTS codes."USER_SEQ"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 100;

CREATE TABLE IF NOT EXISTS USERS.USERS
CREATE TABLE IF NOT EXISTS codes.USERS
(
ID numeric not null
constraint "USER_PK"
primary key DEFAULT nextval('USERS."USER_SEQ"'),
primary key DEFAULT nextval('codes."USER_SEQ"'),
NAME varchar(200) not null,
EMAIL varchar(200) not null
);
INSERT INTO USERS.USERS (NAME, EMAIL)
INSERT INTO codes.USERS (NAME, EMAIL)
VALUES ('John', '[email protected]'),
('Jane', '[email protected]'),
('Jack', '[email protected]'),
Expand Down
2 changes: 1 addition & 1 deletion migrations/sql/V1.0.1__alter_user_seq.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ALTER SEQUENCE USERS."USER_SEQ" RESTART WITH 6 CACHE 1;
ALTER SEQUENCE codes."USER_SEQ" RESTART WITH 6 CACHE 1;
Loading

0 comments on commit 4f63de5

Please sign in to comment.