Skip to content

midgleyc/east-mysql2

Repository files navigation

east mysql2

MySQL adapter for east which uses the Promisified mysql2 driver.

Requires Node 16+ for v2, Node 10+ for v1.

All executed migrations names will by default be stored in a _migrations collection in the _migrations database.

client passed to migrate and rollback functions is an object containing "db" which is a Connection object as returned by mysql2/promise's createConnection.

Use as await client.db.query("SQL").

Configuration

Provide login configuration using environment variables: MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD

or in .eastrc:

{
    "mysql": {
        "host": "remote_host",
        "port": 3307, // note the lack of quotes!
        "user": "custom_user",
        "password": "my_password",
    }
}

host defaults to localhost. port defaults to 3306. Note that port is specified as a number, not a string.

You can also configure the database and table migration information is stored in.

{
    "mysql": {
        "migrationDatabase": "__migrations",
        "migrationTable": "migration_table"
    }
}

migrationDatabase defaults to _migrations. migrationTable also defaults to _migrations.

migrationDatabase is created by default if it does not exist. If you do not want this behaviour, add in .eastrc

{
    "mysql": {
        "createDbOnConnect": false
    }
}

About

node-mysql2 adapter for east

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •