-
Notifications
You must be signed in to change notification settings - Fork 276
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
Conversation
@@ -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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 $$ |
adding primary key to role tables
No description provided.