Skip to content

Commit

Permalink
Mysql compatibility (#27)
Browse files Browse the repository at this point in the history
* MySQL Support!

* MySQL Compatibility

* Test against mysql

* docs

* Update CI db-setup script

* Ensure mysql native bindings are installed when testing mysql in CI

* Lower case table names in CI

* Use default login path for MySQL

* Override client login path

* Use root to assign user privileges

* restart mysql service in CI after config change

* Attempt to config MySQL in CI before npm install

* MySQL TitleCase table names

* TitleCase for all table names

* Dashboard queries refer to tables in TitleCase

* Normalize sql queries for mysql

* RDBMS agnostic null checking
  • Loading branch information
mike-north authored Mar 10, 2018
1 parent b207891 commit 76ef624
Show file tree
Hide file tree
Showing 22 changed files with 639,734 additions and 639,310 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
node_modules
dist
!master.sqlite
scratch.sql
scratch.*
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js

services:
- postgresql
- mysql

sudo: required

Expand All @@ -15,6 +16,12 @@ addons:

matrix:
include:
- node_js: '6'
env: DB_TYPE=mysql
- node_js: '8'
env: DB_TYPE=mysql
- node_js: 'stable'
env: DB_TYPE=mysql
- node_js: '6'
env: DB_TYPE=pg
- node_js: '8'
Expand All @@ -28,11 +35,16 @@ matrix:
- node_js: 'stable'
env: DB_TYPE=sqlite

before_install:
- echo "[mysqld]" > $HOME/.my.cnf
- echo "lower-case-table-names = 1" >> $HOME/.my.cnf
- mysql_config_editor set --login-path=client --host=localhost --user=root
- sudo service mysql restart

install:
- if [ "$DB_TYPE" == "pg" ]; then npm install --no-shrinkwrap; else npm install --no-shrinkwrap --no-optional; fi
- if [ "$DB_TYPE" == "sqlite" ]; then npm install --no-shrinkwrap --no-optional; else npm install --no-shrinkwrap; fi

before_script:
- heroku pg:info --app damp-oasis-38940
- ./scripts/ci/setup-db.sh

script:
Expand Down
41 changes: 41 additions & 0 deletions MYSQL_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Setting up MySQL

## OS X

### Option 1 - Homebrew

1. First, make sure you have homebrew installed
2. Run `brew doctor` and address anything homebrew wants you to fix
3. Run `brew install mysql`
4. Run `brew services restart mysql`
5. Run `mysql.server start`
6. Run `mysql_secure_installation`

## Windows

1. Grab the [the appropriate windows installer](https://www.postgresql.org/download/windows/) and run it.
2. Put the DLLs in your `C:\WINDOWS\system32` folder

## Linux

Use `apt-get` or equivalent.


## All

Once you've installed mysql, you can test your installation with a user of your choice (we'll use the `root` user) by running
```sh
mysqlshow -uroot -p
```

Finally, you'll need to create a login config file with the database's master username and password. Replace `root` with the master user account for your database if necessary

```sh
mysql_config_editor set --login-path=local --host=localhost --user=root --password
```

You should now be able to run
```sh
mysqlshow --login-path=local
```
without having to provide a password in the CLI.
10 changes: 9 additions & 1 deletion database.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@
"host": "localhost",
"database": "nw_postgresql",
"schema": "public"
},
"mysql": {
"driver": "mysql",
"port": 3306,
"user": "northwind_user",
"password": "theWindi$bl0wing",
"host": "localhost",
"database": "northwind"
}
}
}
Binary file modified master.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion migrations/sqls/20171203034929-first-down.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-- DROP TABLE Test;
DROP TABLE NewTable;
8 changes: 4 additions & 4 deletions migrations/sqls/20171203034929-first-up.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- CREATE TABLE Test (
-- id INTEGER PRIMARY KEY,
-- name TEXT NOT NULL
-- );
CREATE TABLE NewTable (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
);
Loading

0 comments on commit 76ef624

Please sign in to comment.