dolphinscheduler_ddl.sql 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. -- uc_dolphin_T_t_ds_worker_group_A_ip_list
  18. delimiter d//
  19. CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_worker_group_A_ip_list() RETURNS void AS $$
  20. BEGIN
  21. IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
  22. WHERE TABLE_NAME='t_ds_worker_group'
  23. AND COLUMN_NAME ='ip_list')
  24. THEN
  25. ALTER TABLE t_ds_worker_group RENAME ip_list TO addr_list;
  26. ALTER TABLE t_ds_worker_group ALTER COLUMN addr_list type text;
  27. ALTER TABLE t_ds_worker_group ALTER COLUMN name type varchar(255), ALTER COLUMN name SET NOT NULL;
  28. ALTER TABLE t_ds_worker_group ADD CONSTRAINT name_unique UNIQUE (name);
  29. END IF;
  30. END;
  31. $$ LANGUAGE plpgsql;
  32. d//
  33. delimiter ;
  34. SELECT uc_dolphin_T_t_ds_worker_group_A_ip_list();
  35. DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_worker_group_A_ip_list();
  36. -- uc_dolphin_T_qrtz_fired_triggers_A_entry_id
  37. delimiter d//
  38. CREATE OR REPLACE FUNCTION uc_dolphin_T_qrtz_fired_triggers_A_entry_id() RETURNS void AS $$
  39. BEGIN
  40. IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
  41. WHERE TABLE_NAME='qrtz_fired_triggers'
  42. AND COLUMN_NAME ='entry_id')
  43. THEN
  44. ALTER TABLE qrtz_fired_triggers ALTER COLUMN entry_id type varchar(200);
  45. END IF;
  46. END;
  47. $$ LANGUAGE plpgsql;
  48. d//
  49. delimiter ;
  50. SELECT uc_dolphin_T_qrtz_fired_triggers_A_entry_id();
  51. DROP FUNCTION IF EXISTS uc_dolphin_T_qrtz_fired_triggers_A_entry_id();
  52. -- Add foreign key constraints for t_ds_task_instance --
  53. delimiter ;
  54. ALTER TABLE t_ds_task_instance ADD CONSTRAINT foreign_key_instance_id FOREIGN KEY(process_instance_id) REFERENCES t_ds_process_instance(id) ON DELETE CASCADE;