diff --git a/src/main/resources/db/h2/schema.sql b/src/main/resources/db/h2/schema.sql index 450045379a8..7e4bf0a0133 100644 --- a/src/main/resources/db/h2/schema.sql +++ b/src/main/resources/db/h2/schema.sql @@ -31,10 +31,12 @@ ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIG CREATE TABLE types ( id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + uuid UUID DEFAULT RANDOM_UUID() NOT NULL UNIQUE, -- Added UUID name VARCHAR(80) ); CREATE INDEX types_name ON types (name); +-- Add UUID to owners table CREATE TABLE owners ( id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, uuid UUID DEFAULT RANDOM_UUID() NOT NULL UNIQUE, -- Added UUID @@ -46,6 +48,7 @@ CREATE TABLE owners ( ); CREATE INDEX owners_last_name ON owners (last_name); +-- Add UUID to pets table CREATE TABLE pets ( id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, uuid UUID DEFAULT RANDOM_UUID() NOT NULL UNIQUE, -- Added UUID @@ -58,6 +61,7 @@ ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types (id); CREATE INDEX pets_name ON pets (name); +-- Add UUID to visits table CREATE TABLE visits ( id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, uuid UUID DEFAULT RANDOM_UUID() NOT NULL UNIQUE, -- Added UUID diff --git a/src/main/resources/db/mysql/data.sql b/src/main/resources/db/mysql/data.sql index 061ba49f9d0..2b31be73e8a 100644 --- a/src/main/resources/db/mysql/data.sql +++ b/src/main/resources/db/mysql/data.sql @@ -2,11 +2,11 @@ INSERT IGNORE INTO specialties (id, name, uuid) VALUES (1, 'radiology', '0a6d743 INSERT IGNORE INTO specialties (id, name, uuid) VALUES (2, 'surgery', 'e3a10a00-4567-4c98-89ba-d7bb3e9a999a'); INSERT IGNORE INTO specialties (id, name, uuid) VALUES (3, 'dentistry', '1a78df21-5678-4b5a-ae13-88f72065b4b1'); -INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (2, 1, 'ecb2f7b9-789a-4d2e-8c6b-51254c3f9d2c'); -INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (3, 2, '1f91f6b9-890b-4e6f-92c7-98254a5e3d42'); -INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (3, 3, '6c023456-9b5b-40d1-96fc-d3543b6e5f24'); -INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (4, 2, '74ab9db9-9bfc-44b1-897c-54f35c2c4f65'); -INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (5, 1, '59ba1d9e-123c-4c3b-bc78-9e44efc1a523'); +INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (2, 1); +INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (3, 2); +INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (3, 3); +INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (4, 2); +INSERT IGNORE INTO vet_specialties (vet_id, specialty_id, uuid) VALUES (5, 1); INSERT IGNORE INTO types (id, name, uuid) VALUES (1, 'cat', '9a7b1789-5678-4c23-b90c-ef3f82c3bcde'); INSERT IGNORE INTO types (id, name, uuid) VALUES (2, 'dog', '3b8a2a12-4567-4c56-bb12-d3b50efc23b2'); diff --git a/src/main/resources/db/mysql/schema.sql b/src/main/resources/db/mysql/schema.sql index 5c5b1a6292e..23a6fd5892c 100644 --- a/src/main/resources/db/mysql/schema.sql +++ b/src/main/resources/db/mysql/schema.sql @@ -15,7 +15,6 @@ CREATE TABLE IF NOT EXISTS specialties ( CREATE TABLE IF NOT EXISTS vet_specialties ( vet_id INT(4) UNSIGNED NOT NULL, - uuid CHAR(36) NOT NULL DEFAULT (UUID()) UNIQUE, specialty_id INT(4) UNSIGNED NOT NULL, FOREIGN KEY (vet_id) REFERENCES vets(id), FOREIGN KEY (specialty_id) REFERENCES specialties(id), diff --git a/src/main/resources/db/postgres/data.sql b/src/main/resources/db/postgres/data.sql index c24615d8bce..b83a3a7567e 100644 --- a/src/main/resources/db/postgres/data.sql +++ b/src/main/resources/db/postgres/data.sql @@ -34,24 +34,24 @@ INSERT INTO specialties (name, uuid) SELECT 'dentistry', gen_random_uuid() WHERE NOT EXISTS (SELECT * FROM specialties WHERE name='dentistry'); -INSERT INTO vet_specialties (vet_id, specialty_id, uuid) -VALUES (2, 1, gen_random_uuid()) +INSERT INTO vet_specialties (vet_id, specialty_id) +VALUES (2, 1) ON CONFLICT (vet_id, specialty_id) DO NOTHING; -INSERT INTO vet_specialties (vet_id, specialty_id, uuid) -VALUES (3, 2, gen_random_uuid()) +INSERT INTO vet_specialties (vet_id, specialty_id) +VALUES (3, 2) ON CONFLICT (vet_id, specialty_id) DO NOTHING; -INSERT INTO vet_specialties (vet_id, specialty_id, uuid) -VALUES (3, 3, gen_random_uuid()) +INSERT INTO vet_specialties (vet_id, specialty_id) +VALUES (3, 3) ON CONFLICT (vet_id, specialty_id) DO NOTHING; -INSERT INTO vet_specialties (vet_id, specialty_id, uuid) -VALUES (4, 2, gen_random_uuid()) +INSERT INTO vet_specialties (vet_id, specialty_id) +VALUES (4, 2) ON CONFLICT (vet_id, specialty_id) DO NOTHING; -INSERT INTO vet_specialties (vet_id, specialty_id, uuid) -VALUES (5, 1, gen_random_uuid()) +INSERT INTO vet_specialties (vet_id, specialty_id) +VALUES (5, 1) ON CONFLICT (vet_id, specialty_id) DO NOTHING; INSERT INTO types (name, uuid) diff --git a/src/main/resources/db/postgres/schema.sql b/src/main/resources/db/postgres/schema.sql index f7804537161..34d2aaeb421 100644 --- a/src/main/resources/db/postgres/schema.sql +++ b/src/main/resources/db/postgres/schema.sql @@ -16,7 +16,6 @@ CREATE INDEX ON specialties (name); CREATE TABLE IF NOT EXISTS vet_specialties ( vet_id INT NOT NULL REFERENCES vets (id), specialty_id INT NOT NULL REFERENCES specialties (id), - uuid UUID DEFAULT gen_random_uuid() UNIQUE, UNIQUE (vet_id, specialty_id) );