File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
dao/src/main/resources/sql Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -242,10 +242,17 @@ CREATE TABLE IF NOT EXISTS device_profile (
242
242
CONSTRAINT fk_software_device_profile FOREIGN KEY (software_id) REFERENCES ota_package(id)
243
243
);
244
244
245
- ALTER TABLE ota_package
246
- ADD CONSTRAINT fk_device_profile_ota_package
247
- FOREIGN KEY (device_profile_id) REFERENCES device_profile (id)
248
- ON DELETE CASCADE ;
245
+ DO
246
+ $$
247
+ BEGIN
248
+ IF NOT EXISTS(SELECT 1 FROM pg_constraint WHERE conname = ' fk_device_profile_ota_package' ) THEN
249
+ ALTER TABLE ota_package
250
+ ADD CONSTRAINT fk_device_profile_ota_package
251
+ FOREIGN KEY (device_profile_id) REFERENCES device_profile (id)
252
+ ON DELETE CASCADE ;
253
+ END IF;
254
+ END;
255
+ $$;
249
256
250
257
-- We will use one-to-many relation in the first release and extend this feature in case of user requests
251
258
-- CREATE TABLE IF NOT EXISTS device_profile_firmware (
You can’t perform that action at this time.
0 commit comments