db-migrate / node-db-migrate

Database migration framework for node
Other
2.32k stars 360 forks source link

Db migrate not running migrations for mysql #749

Closed Xexnon closed 2 years ago

Xexnon commented 2 years ago

I'm submitting a...

Current behavior

Throws a syntax error while running migrations but runs correctly on MySQL workbench

Expected behavior

should run migration correctly

Minimal reproduction of the problem with instructions

This is the MySQL migration file.

/* Replace with your SQL commands */
CREATE TABLE IF NOT EXISTS user_info(
  id BINARY(16) PRIMARY KEY,
  first_name VARCHAR(100) NOT NULL,
  last_name VARCHAR(100) NOT NULL,
  email VARCHAR(150) UNIQUE NOT NULL,
  password VARCHAR(100) NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT NOW(),
  updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
);

CREATE TABLE IF NOT EXISTS wallet(
  id BINARY(16) PRIMARY KEY,
  user_id BINARY(16) NOT NULL,
  balance DECIMAL(19,4) NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT NOW(),
  updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(),
  FOREIGN KEY (user_id) REFERENCES user_info(id)
);

is it that I can't run multiple create at once cos this works on db-migrate-pg driver whats the problem with MySQL driver

What is the motivation / use case for changing the behavior?

Environment


db-migrate version: 0.11.12
plugins with versions: X.Y.Z
db-migrate driver with versions: mysql 2.1.2  

Additional information:
- Node version: 14.x  
- Platform: Mac 

Others:

wzrdtales commented 2 years ago

please read the docs: https://db-migrate.readthedocs.io/en/latest/Getting%20Started/configuration/

Xexnon commented 2 years ago

please read the docs: https://db-migrate.readthedocs.io/en/latest/Getting%20Started/configuration/ is this config correct

{
  "development": {
    "ENV": "DATABASE_DEV_URL",
    "driver": "mysql",
    "multipleStatements": true
  },
  "test": {
    "ENV": "DATABASE_TEST_URL",
    "driver": "mysql",
    "multipleStatements": true
  },
  "production": {
    "ENV": "DATABASE_URL",
    "driver": "mysql",
    "multipleStatements": true
  },
  "defaultEnv": {
    "ENV": "NODE_ENV"
  },
  "sql-file": true
}
Xexnon commented 2 years ago

please read the docs: https://db-migrate.readthedocs.io/en/latest/Getting%20Started/configuration/

I did that already and set my database.json file it wan't working