|
@@ -29,16 +29,7 @@ ALTER TABLE ambari.clusterstate
|
|
CREATE TABLE ambari.metainfo ("metainfo_key" VARCHAR(255), "metainfo_value" VARCHAR, PRIMARY KEY("metainfo_key"));
|
|
CREATE TABLE ambari.metainfo ("metainfo_key" VARCHAR(255), "metainfo_value" VARCHAR, PRIMARY KEY("metainfo_key"));
|
|
GRANT ALL PRIVILEGES ON TABLE ambari.metainfo TO :username;
|
|
GRANT ALL PRIVILEGES ON TABLE ambari.metainfo TO :username;
|
|
|
|
|
|
-CREATE TABLE ambari.clusterconfigmapping (cluster_id bigint NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL, create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (cluster_id, type_name, create_timestamp));
|
|
|
|
-GRANT ALL PRIVILEGES ON TABLE ambari.clusterconfigmapping TO :username;
|
|
|
|
-ALTER TABLE ambari.clusterconfigmapping ADD CONSTRAINT FK_clusterconfigmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
|
|
|
|
-INSERT INTO ambari.clusterconfigmapping(cluster_id, type_name, version_tag, create_timestamp, selected)
|
|
|
|
- (SELECT DISTINCT cluster_id, config_type, config_tag, cast(date_part('epoch', now()) as bigint), 1
|
|
|
|
- FROM ambari.serviceconfigmapping scm
|
|
|
|
- WHERE timestamp = (SELECT max(timestamp) FROM ambari.serviceconfigmapping WHERE cluster_id = scm.cluster_id AND config_type = scm.config_type));
|
|
|
|
-DELETE FROM ambari.serviceconfigmapping;
|
|
|
|
-
|
|
|
|
-CREATE TABLE ambari.hostconfigmapping (cluster_id bigint NOT NULL, host_name VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL, service_name VARCHAR(255), create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (cluster_id, host_name, type_name, create_timestamp));
|
|
|
|
|
|
+CREATE TABLE ambari.hostconfigmapping (cluster_id bigint NOT NULL, host_name VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL, service_name VARCHAR(255), create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (cluster_id, host_name, type_name, create_timestamp));
|
|
GRANT ALL PRIVILEGES ON TABLE ambari.hostconfigmapping TO :username;
|
|
GRANT ALL PRIVILEGES ON TABLE ambari.hostconfigmapping TO :username;
|
|
ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT FK_hostconfigmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
|
|
ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT FK_hostconfigmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
|
|
ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT FK_hostconfigmapping_host_name FOREIGN KEY (host_name) REFERENCES ambari.hosts (host_name);
|
|
ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT FK_hostconfigmapping_host_name FOREIGN KEY (host_name) REFERENCES ambari.hosts (host_name);
|
|
@@ -79,3 +70,37 @@ COMMIT;
|
|
|
|
|
|
UPDATE ambari.hostcomponentstate SET current_state = 'INSTALLED' WHERE current_state like 'STOP_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';
|
|
UPDATE ambari.hostcomponentstate SET current_state = 'INSTALLED' WHERE current_state like 'START_FAILED';
|
|
|
|
+
|
|
|
|
+-- service to cluster level config mappings move. idempotent update
|
|
|
|
+
|
|
|
|
+CREATE LANGUAGE plpgsql;
|
|
|
|
+
|
|
|
|
+CREATE OR REPLACE FUNCTION update_clusterconfigmapping()
|
|
|
|
+ RETURNS void AS
|
|
|
|
+$_$
|
|
|
|
+BEGIN
|
|
|
|
+
|
|
|
|
+IF NOT EXISTS (
|
|
|
|
+ SELECT *
|
|
|
|
+ FROM pg_catalog.pg_tables
|
|
|
|
+ WHERE schemaname = 'ambari'
|
|
|
|
+ AND tablename = 'clusterconfigmapping'
|
|
|
|
+ )
|
|
|
|
+ THEN
|
|
|
|
+
|
|
|
|
+ CREATE TABLE ambari.clusterconfigmapping (cluster_id bigint NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL, create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (cluster_id, type_name, create_timestamp));
|
|
|
|
+ ALTER TABLE ambari.clusterconfigmapping ADD CONSTRAINT FK_clusterconfigmapping_cluster_id FOREIGN KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
|
|
|
|
+ INSERT INTO ambari.clusterconfigmapping(cluster_id, type_name, version_tag, create_timestamp, selected)
|
|
|
|
+ (SELECT DISTINCT cluster_id, config_type, config_tag, cast(date_part('epoch', now()) as bigint), 1
|
|
|
|
+ FROM ambari.serviceconfigmapping scm
|
|
|
|
+ WHERE timestamp = (SELECT max(timestamp) FROM ambari.serviceconfigmapping WHERE cluster_id = scm.cluster_id AND config_type = scm.config_type));
|
|
|
|
+ DELETE FROM ambari.serviceconfigmapping;
|
|
|
|
+
|
|
|
|
+END IF;
|
|
|
|
+
|
|
|
|
+END;
|
|
|
|
+$_$ LANGUAGE plpgsql;
|
|
|
|
+
|
|
|
|
+SELECT update_clusterconfigmapping();
|
|
|
|
+GRANT ALL PRIVILEGES ON TABLE ambari.clusterconfigmapping TO :username;
|
|
|
|
+
|