Browse Source

Fix install script for fk_device_profile_ota_package constraint to work on repeated install

pull/6330/head
Viacheslav Klimov 5 years ago
parent
commit
50422363f0
  1. 15
      dao/src/main/resources/sql/schema-entities.sql

15
dao/src/main/resources/sql/schema-entities.sql

@ -242,10 +242,17 @@ CREATE TABLE IF NOT EXISTS device_profile (
CONSTRAINT fk_software_device_profile FOREIGN KEY (software_id) REFERENCES ota_package(id) CONSTRAINT fk_software_device_profile FOREIGN KEY (software_id) REFERENCES ota_package(id)
); );
ALTER TABLE ota_package DO
ADD CONSTRAINT fk_device_profile_ota_package $$
FOREIGN KEY (device_profile_id) REFERENCES device_profile (id) BEGIN
ON DELETE CASCADE; IF NOT EXISTS(SELECT 1 FROM pg_constraint WHERE conname = 'fk_device_profile_ota_package') THEN
ALTER TABLE ota_package
ADD CONSTRAINT fk_device_profile_ota_package
FOREIGN KEY (device_profile_id) REFERENCES device_profile (id)
ON DELETE CASCADE;
END IF;
END;
$$;
-- We will use one-to-many relation in the first release and extend this feature in case of user requests -- We will use one-to-many relation in the first release and extend this feature in case of user requests
-- CREATE TABLE IF NOT EXISTS device_profile_firmware ( -- CREATE TABLE IF NOT EXISTS device_profile_firmware (

Loading…
Cancel
Save