|
@@ -54,6 +54,7 @@ ALTER TABLE ambari.hosts
|
|
|
-- Upgrade to 1.3.0
|
|
|
|
|
|
-- setting run-time search_path for :username
|
|
|
+ALTER SCHEMA ambari OWNER TO :username;
|
|
|
ALTER ROLE :username SET search_path to 'ambari';
|
|
|
|
|
|
--updating clusterstate table
|
|
@@ -72,34 +73,36 @@ ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT FK_hostconfigmapping_host_na
|
|
|
ALTER TABLE ambari.stage ADD COLUMN request_context VARCHAR(255);
|
|
|
|
|
|
-- portability changes for MySQL/Oracle support
|
|
|
-alter table ambari.hostcomponentdesiredconfigmapping rename to hcdesiredconfigmapping;
|
|
|
-alter table ambari.users alter column user_id drop default;
|
|
|
-alter table ambari.users alter column ldap_user type INTEGER using case when ldap_user=true then 1 else 0 END;
|
|
|
+ALTER TABLE ambari.hostcomponentdesiredconfigmapping rename to hcdesiredconfigmapping;
|
|
|
+ALTER TABLE ambari.users ALTER column user_id DROP DEFAULT;
|
|
|
+ALTER TABLE ambari.users ALTER column ldap_user TYPE INTEGER USING CASE WHEN ldap_user=true THEN 1 ELSE 0 END;
|
|
|
|
|
|
--creating ambari_sequences table instead of deprecated sequences
|
|
|
CREATE TABLE ambari.ambari_sequences (sequence_name VARCHAR(255) PRIMARY KEY, "value" BIGINT NOT NULL);
|
|
|
GRANT ALL PRIVILEGES ON TABLE ambari.ambari_sequences TO :username;
|
|
|
|
|
|
-insert into ambari.ambari_sequences(sequence_name, "value")
|
|
|
- select 'cluster_id_seq', nextval('ambari.clusters_cluster_id_seq')
|
|
|
- union all
|
|
|
- select 'user_id_seq', nextval('ambari.users_user_id_seq')
|
|
|
- union all
|
|
|
- select 'host_role_command_id_seq', coalesce((select max(task_id) from ambari.host_role_command), 1) + 50;
|
|
|
+INSERT INTO ambari.ambari_sequences(sequence_name, "value")
|
|
|
+ SELECT 'cluster_id_seq', nextval('ambari.clusters_cluster_id_seq')
|
|
|
+ UNION ALL
|
|
|
+ SELECT 'user_id_seq', nextval('ambari.users_user_id_seq')
|
|
|
+ UNION ALL
|
|
|
+ SELECT 'host_role_command_id_seq', COALESCE((SELECT max(task_id) FROM ambari.host_role_command), 1) + 50
|
|
|
+ UNION ALL
|
|
|
+ SELECT 'configgroup_id_seq', 1;
|
|
|
|
|
|
-drop sequence ambari.host_role_command_task_id_seq;
|
|
|
-drop sequence ambari.users_user_id_seq;
|
|
|
-drop sequence ambari.clusters_cluster_id_seq;
|
|
|
+DROP sequence ambari.host_role_command_task_id_seq;
|
|
|
+DROP sequence ambari.users_user_id_seq;
|
|
|
+DROP sequence ambari.clusters_cluster_id_seq;
|
|
|
|
|
|
--updating metainfo table
|
|
|
CREATE TABLE ambari.metainfo (metainfo_key VARCHAR(255), metainfo_value VARCHAR, PRIMARY KEY(metainfo_key));
|
|
|
-INSERT INTO ambari.metainfo (metainfo_key, metainfo_value) select 'version', '${ambariVersion}';
|
|
|
+INSERT INTO ambari.metainfo (metainfo_key, metainfo_value) SELECT 'version', '${ambariVersion}';
|
|
|
UPDATE ambari.metainfo SET metainfo_value = '${ambariVersion}' WHERE metainfo_key = 'version';
|
|
|
GRANT ALL PRIVILEGES ON TABLE ambari.metainfo TO :username;
|
|
|
|
|
|
--replacing deprecated STOP_FAILED and START_FAILED states with INSTALLED
|
|
|
-UPDATE ambari.hostcomponentstate SET current_state = 'INSTALLED' WHERE current_state like 'STOP_FAILED';
|
|
|
-UPDATE ambari.hostcomponentstate SET current_state = 'INSTALLED' WHERE current_state like 'START_FAILED';
|
|
|
+UPDATE ambari.hostcomponentstate SET current_state = 'INSTALLED' WHERE current_state LIKE 'STOP_FAILED';
|
|
|
+UPDATE ambari.hostcomponentstate SET current_state = 'INSTALLED' WHERE current_state LIKE 'START_FAILED';
|
|
|
|
|
|
--updating clusterconfigmapping table
|
|
|
ALTER TABLE ambari.clusterconfigmapping
|
|
@@ -107,3 +110,24 @@ ALTER TABLE ambari.clusterconfigmapping
|
|
|
SELECT update_clusterconfigmapping();
|
|
|
GRANT ALL PRIVILEGES ON TABLE ambari.clusterconfigmapping TO :username;
|
|
|
|
|
|
+-- drop deprecated tables componentconfigmapping and hostcomponentconfigmapping
|
|
|
+-- not required after Config Group implementation
|
|
|
+--DROP TABLE componentconfigmapping;
|
|
|
+--DROP TABLE hostcomponentconfigmapping;
|
|
|
+
|
|
|
+-- required for Config Group implementation
|
|
|
+CREATE TABLE ambari.configgroup (group_id BIGINT, cluster_id BIGINT NOT NULL, group_name VARCHAR(255) NOT NULL, tag VARCHAR(1024) NOT NULL, description VARCHAR(1024), create_timestamp BIGINT NOT NULL, PRIMARY KEY(group_id), UNIQUE(group_name));
|
|
|
+GRANT ALL PRIVILEGES ON TABLE ambari.configgroup TO :username;
|
|
|
+
|
|
|
+CREATE TABLE ambari.confgroupclusterconfigmapping (config_group_id BIGINT NOT NULL, cluster_id BIGINT NOT NULL, config_type VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL, user_name VARCHAR(255) DEFAULT '_db', create_timestamp BIGINT NOT NULL, PRIMARY KEY(config_group_id, cluster_id, config_type));
|
|
|
+GRANT ALL PRIVILEGES ON TABLE ambari.confgroupclusterconfigmapping TO :username;
|
|
|
+
|
|
|
+CREATE TABLE ambari.configgrouphostmapping (config_group_id BIGINT NOT NULL, host_name VARCHAR(255) NOT NULL, PRIMARY KEY(config_group_id, host_name));
|
|
|
+GRANT ALL PRIVILEGES ON TABLE ambari.configgrouphostmapping TO :username;
|
|
|
+
|
|
|
+ALTER TABLE ambari.configgroup ADD CONSTRAINT FK_configgroup_cluster_id FOREIGN KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
|
|
|
+ALTER TABLE ambari.confgroupclusterconfigmapping ADD CONSTRAINT FK_confgroupclusterconfigmapping_config_tag FOREIGN KEY (version_tag, config_type, cluster_id) REFERENCES ambari.clusterconfig (version_tag, type_name, cluster_id);
|
|
|
+ALTER TABLE ambari.confgroupclusterconfigmapping ADD CONSTRAINT FK_confgroupclusterconfigmapping_group_id FOREIGN KEY (config_group_id) REFERENCES ambari.configgroup (group_id);
|
|
|
+ALTER TABLE ambari.configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_configgroup_id FOREIGN KEY (config_group_id) REFERENCES ambari.configgroup (group_id);
|
|
|
+ALTER TABLE ambari.configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_host_name FOREIGN KEY (host_name) REFERENCES ambari.hosts (host_name);
|
|
|
+
|