Skip to content

Commit

Permalink
Merge "[FAB-4211] WIP: Allow zero date values MySQL"
Browse files Browse the repository at this point in the history
  • Loading branch information
binhn authored and Gerrit Code Review committed Jun 9, 2017
2 parents 25d8150 + 037b407 commit 7555a9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions docs/source/users-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,19 @@ The following sample may be added to the Fabric CA server configuration file in
order to connect to a MySQL database. Be sure to customize the various
values appropriately.

On MySQL 5.7.X, certain modes affect whether the server permits '0000-00-00' as a valid date.
It might be necessary to relax the modes that MySQL server uses. We want to allow
the server to be able to accept zero date values.

In my.cnf, find the configuration option *sql_mode* and remove *NO_ZERO_DATE* if present.
Restart MySQL server after making this change.

Please refer to the following MySQL documentation on different modes available
and select the appropriate settings for the specific version of MySQL that is
being used.

https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html

::

db:
Expand Down Expand Up @@ -1546,16 +1559,6 @@ https://www.postgresql.org/docs/9.4/static/libpq-ssl.html
MySQL SSL Configuration
~~~~~~~~~~~~~~~~~~~~~~~

On MySQL 5.7.X, certain modes affect whether the server permits '0000-00-00' as a valid date.
It might be necessary to relax the modes that MySQL server uses. We want to allow
the server to be able to accept zero date values.

Please refer to the following MySQL documentation on different modes available
and select the appropriate settings for the specific version of MySQL that is
being used.

https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html

**Basic instructions for configuring SSL on MySQL server:**

1. Open or create my.cnf file for the server. Add or uncomment the
Expand Down
2 changes: 1 addition & 1 deletion lib/dbutil/dbutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func createMySQLTables(datasource string, dbName string, db *sqlx.DB) error {
return fmt.Errorf("Error creating affiliations table: %s", err)
}
log.Debug("Created affiliations table")
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 {
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 0, revoked_at timestamp DEFAULT 0, pem varbinary(4096) NOT NULL, PRIMARY KEY(serial_number, authority_key_identifier)) DEFAULT CHARSET=utf8 COLLATE utf8_bin"); err != nil {
return fmt.Errorf("Error creating certificates table: %s", err)
}
log.Debug("Created certificates table")
Expand Down

0 comments on commit 7555a9b

Please sign in to comment.