You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ambari.apache.org by "Dmytro Sen (JIRA)" <ji...@apache.org> on 2017/10/25 16:54:00 UTC

[jira] [Created] (AMBARI-22309) Update db schema to use service_id instead of service_name

Dmytro Sen created AMBARI-22309:
-----------------------------------

             Summary: Update db schema to use service_id instead of service_name
                 Key: AMBARI-22309
                 URL: https://issues.apache.org/jira/browse/AMBARI-22309
             Project: Ambari
          Issue Type: Bug
          Components: ambari-server
    Affects Versions: 3.0.0
            Reporter: Dmytro Sen
            Assignee: Dmytro Sen
            Priority: Critical
             Fix For: 3.0.0


As part of AMBARI-21824, we added {{id}} to {{clusterservices}} table. We updated tables to use the service_id as foreign key instead of service_name. 

https://github.com/apache/ambari/blob/branch-feature-AMBARI-14714/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql

For example: 
{code}
CREATE TABLE servicecomponentdesiredstate (
  id BIGINT NOT NULL,
  component_name VARCHAR(255) NOT NULL,
  cluster_id BIGINT NOT NULL,
  service_group_id BIGINT NOT NULL,
  service_id BIGINT NOT NULL,
  desired_repo_version_id BIGINT NOT NULL,
  desired_state VARCHAR(255) NOT NULL,
  recovery_enabled SMALLINT NOT NULL DEFAULT 0,
  repo_state VARCHAR(255) NOT NULL DEFAULT 'NOT_REQUIRED',
  CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
  CONSTRAINT UQ_scdesiredstate_name UNIQUE(component_name, service_id, service_group_id, cluster_id),
  CONSTRAINT FK_scds_desired_repo_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id),
  CONSTRAINT srvccmponentdesiredstatesrvcnm FOREIGN KEY (service_id, service_group_id, cluster_id) REFERENCES clusterservices (id, service_group_id, cluster_id));
{code}

We need to update other DB tables to use service_id instead of service_name. 

For example: 
{code}
CREATE TABLE serviceconfig (
  service_config_id BIGINT NOT NULL,
  cluster_id BIGINT NOT NULL,
  service_name VARCHAR(255) NOT NULL,
  version BIGINT NOT NULL,
  create_timestamp BIGINT NOT NULL,
  stack_id BIGINT NOT NULL,
  user_name VARCHAR(255) NOT NULL DEFAULT '_db',
  group_id BIGINT,
  note TEXT,
  CONSTRAINT PK_serviceconfig PRIMARY KEY (service_config_id),
  CONSTRAINT FK_serviceconfig_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id),
  CONSTRAINT UQ_scv_service_version UNIQUE (cluster_id, service_name, version));
{code}





--
This message was sent by Atlassian JIRA
(v6.4.14#64029)