-- Migration from 063 to 064

-- Add SCRIPT_TYPE column to SCRIPTS
CREATE DOMAIN script_type AS VARCHAR(40) CHECK (VALUE IN ('DYNAMIC_PROPERTY', 'MANAGED_PROPERTY'));
ALTER TABLE scripts ADD COLUMN script_type script_type;
UPDATE scripts SET script_type = 'DYNAMIC_PROPERTY';
ALTER TABLE SCRIPTS ALTER COLUMN SCRIPT_TYPE SET NOT NULL; 

-- Remove redundant IS_DYNAMIC column from *_PROPERTY_TYPES tables 

ALTER TABLE MATERIAL_TYPE_PROPERTY_TYPES DROP COLUMN IS_DYNAMIC;
ALTER TABLE SAMPLE_TYPE_PROPERTY_TYPES DROP COLUMN IS_DYNAMIC;
ALTER TABLE EXPERIMENT_TYPE_PROPERTY_TYPES DROP COLUMN IS_DYNAMIC;
ALTER TABLE DATA_SET_TYPE_PROPERTY_TYPES DROP COLUMN IS_DYNAMIC;