Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Add support for MariaDB/MySQL #1229

Merged
merged 6 commits into from
Sep 8, 2017
Merged

Add support for MariaDB/MySQL #1229

merged 6 commits into from
Sep 8, 2017

Conversation

irfanhabib
Copy link
Contributor

  • Migrates docker-compose environments to deploy mariaDB
  • Updates goose scripts to be go migrations
  • Renames PGSQL_* properties to be DB_*

@irfanhabib
Copy link
Contributor Author

dc.Port,
escapeStr(dc.Database))

log.Printf("DB Connection string: %s:*********tcp(%s:%d)/%s?parseTime=true",
Copy link
Contributor

Choose a reason for hiding this comment

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

@ char missing after the starred-out password

@@ -226,7 +267,7 @@ func Ping(db *sql.DB) error {
// SQLite uses ?
func ModifySQLStatement(sql string, databaseProvider string) string {

if databaseProvider == "sqlite" {
if databaseProvider == "sqlite" || databaseProvider == "mysql" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not use the constants that were added?

@@ -283,9 +286,19 @@ func initSessionStore(db *sql.DB, databaseProvider string, pc interfaces.PortalC
sessionStore.Options.Secure = true
return sessionStore, err
}
// Store depends on the DB Type
if databaseProvider == "mysql" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the constant?

@@ -273,6 +274,8 @@ func initConnPool(dc datastore.DatabaseConfig) (*sql.DB, error) {
func initSessionStore(db *sql.DB, databaseProvider string, pc interfaces.PortalConfig, sessionExpiry int) (HttpSessionStore, error) {
log.Debug("initSessionStore")

sessionsTable := "sessions"

// Store depends on the DB Type
if databaseProvider == "pgsql" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use constant for pgsql ?


_, err := txn.Exec(createTokens)
if err != nil {
fmt.Printf("Failed ot migrate due to: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

typo "ot"

Copy link
Contributor

Choose a reason for hiding this comment

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

The function has no return params - how do we report that the migration failed - all we are doing is printing an error.


_, err = txn.Exec(createCnsisTable)
if err != nil {
fmt.Printf("Failed ot migrate due to: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo "ot"

createIndex := "CREATE INDEX tokens_user_guid ON tokens (user_guid);"
_, err = txn.Exec(createIndex)
if err != nil {
fmt.Printf("Failed ot migrate due to: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo "ot"

createIndex = "CREATE INDEX tokens_cnsi_guid ON tokens (cnsi_guid);"
_, err = txn.Exec(createIndex)
if err != nil {
fmt.Printf("Failed ot migrate due to: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same typo - there are many, please fix!


_, err := txn.Exec(consoleConfigTable)
if err != nil {
fmt.Printf("Failed ot migrate due to: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same typo - many occurrences

@irfanhabib
Copy link
Contributor Author

@nwmac I've addressed all comments. Once this is merged I'll update the PRs that depend on this. This should be merged without squashing, since that will simplify the other PRs

Copy link
Contributor

@nwmac nwmac left a comment

Choose a reason for hiding this comment

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

LGRM

@nwmac nwmac merged commit 429f177 into master Sep 8, 2017
@nwmac nwmac deleted the add-mysql-support branch September 8, 2017 13:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants