-- Migration from 129 to 130

CREATE DOMAIN PLUGIN_TYPE AS VARCHAR(40) CHECK (VALUE IN ('JYTHON', 'PREDEPLOYED'));

ALTER TABLE SCRIPTS ADD COLUMN PLUGIN_TYPE PLUGIN_TYPE NOT NULL DEFAULT 'JYTHON';
ALTER TABLE SCRIPTS ALTER COLUMN SCRIPT DROP NOT NULL;
ALTER TABLE SCRIPTS ADD CONSTRAINT SCRIPT_NN_CK CHECK
  (PLUGIN_TYPE = 'PREDEPLOYED' OR SCRIPT IS NOT NULL);
  
alter table post_registration_dataset_queue drop CONSTRAINT prdq_ds_fk;
alter table post_registration_dataset_queue add CONSTRAINT prdq_ds_fk FOREIGN KEY (ds_id) REFERENCES data_all (id) ON DELETE CASCADE;
  