Skip to content

Commit

Permalink
Case sensitivity for MySQL users table
Browse files Browse the repository at this point in the history
Values that populate the USERS 'name' field is case-sensitive
in postgres, but case-insensitive in mysql. MySQL tables
will now be case sensitive as well to provided consistent
DB behavior.

https://jira.hyperledger.org/browse/FAB-2720

Change-Id: I44644b3a0593ed526b24f2c80e6308137fe83303
Signed-off-by: Saad Karim <[email protected]>
  • Loading branch information
Saad Karim committed Mar 23, 2017
1 parent 894b7e4 commit 2b9daa3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/dbutil/dbutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ func createMySQLTables(datasource string, dbName string, db *sqlx.DB) error {
log.Errorf("Failed to open database (%s), err: %s", dbName, err)
}
log.Debug("Creating Tables...")
if _, err := database.Exec("CREATE TABLE users (id VARCHAR(64) NOT NULL, token blob, type VARCHAR(64), affiliation VARCHAR(64), attributes VARCHAR(256), state INTEGER, max_enrollments INTEGER, PRIMARY KEY (id))"); err != nil {
if _, err := database.Exec("CREATE TABLE users (id VARCHAR(64) NOT NULL, token blob, type VARCHAR(64), affiliation VARCHAR(64), attributes VARCHAR(256), state INTEGER, max_enrollments INTEGER, PRIMARY KEY (id)) DEFAULT CHARSET=utf8 COLLATE utf8_bin"); err != nil {
log.Errorf("Error creating users table [error: %s] ", err)
return err
}
if _, err := database.Exec("CREATE TABLE affiliations (name VARCHAR(64), prekey VARCHAR(64))"); err != nil {
log.Errorf("Error creating affiliations table [error: %s] ", err)
return err
}
if _, err := database.Exec("CREATE TABLE certificates (id VARCHAR(64), serial_number varbinary(128) NOT NULL, authority_key_identifier varbinary(128) NOT NULL, ca_label varbinary(128), status varbinary(128) NOT NULL, reason int, expiry timestamp DEFAULT '1970-01-01 00:00:01', revoked_at timestamp DEFAULT '1970-01-01 00:00:01', pem varbinary(4096) NOT NULL, PRIMARY KEY(serial_number, authority_key_identifier))"); err != nil {
if _, err := database.Exec("CREATE TABLE certificates (id VARCHAR(64), serial_number varbinary(128) NOT NULL, authority_key_identifier varbinary(128) NOT NULL, ca_label varbinary(128), status varbinary(128) NOT NULL, reason int, expiry timestamp DEFAULT '1970-01-01 00:00:01', revoked_at timestamp DEFAULT '1970-01-01 00:00:01', pem varbinary(4096) NOT NULL, PRIMARY KEY(serial_number, authority_key_identifier)) DEFAULT CHARSET=utf8 COLLATE utf8_bin"); err != nil {
log.Errorf("Error creating certificates table [error: %s] ", err)
return err
}
Expand Down

0 comments on commit 2b9daa3

Please sign in to comment.