Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding primary key to role tables #330

Merged
merged 2 commits into from
Sep 27, 2019

Conversation

johnrex-j
Copy link
Contributor

No description provided.

@@ -752,6 +752,8 @@ CREATE TABLE IF NOT EXISTS `oauth_user_role_mapping` (
`modifiedDate` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE oauth_user_role_mapping ADD PRIMARY KEY (userRoleId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnrex-j
Before adding primary key, you should delete all the duplicate values because in all previous deployments, there are duplicate data get loaded into the table because of not having a primary key/unique key and this will make problem to the already installed pacbotstack.
See here,

INSERT IGNORE INTO `oauth_user_role_mapping`(`userRoleId`,`userId`,`roleId`,`clientId`,`allocator`,`createdDate`,`modifiedDate`) values ('4747c0cf-63cc-4829-a1e8-f1e957ec5dd6','user@pacbot.org','1','22e14922-87d7-4ee4-a470-da0bb10d45d3','user123','2018-01-09 16:11:47','2018-01-09 16:11:47'),('4747c0cf-63cc-4829-a1e8-f1e957ec5dd7','admin@pacbot.org','1','22e14922-87d7-4ee4-a470-da0bb10d45d3','user123','2018-01-09 16:11:47','2018-01-09 16:11:47'),('f5b2a689-c185-11e8-9c73-12d01119b604','admin@pacbot.org','703','22e14922-87d7-4ee4-a470-da0bb10d45d3','user123','2018-01-09 16:11:47','2018-01-09 16:11:47');

During each deployemnt when this line get executed duplicate entries are created

@@ -771,6 +773,8 @@ CREATE TABLE IF NOT EXISTS `oauth_user_roles` (
`modifiedDate` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE oauth_user_roles ADD PRIMARY KEY (roleId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of DDL makes problem to the successive DB import as it tries to add primary key to an already existing key. So you should create a procedure for this. Please follow the logic already I added here

DROP PROCEDURE IF EXISTS create_unique_key_if_not_exists $$

@santhoshigorle santhoshigorle merged commit 33cf110 into tmobile:release/1.6 Sep 27, 2019
KanchanaAradhya pushed a commit to KanchanaAradhya/pacbot that referenced this pull request Jan 13, 2020
adding primary key to role tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants