Skip to content

CLI not loading define parameters from the config json to override collate/charsets in MySQL dialect. #953

@coderkoala

Description

@coderkoala

What you are doing?

When running a migration init from the sequelize-cli itself, the collation always defaults to latin_ci for all tables, even if overridden using the config.json file. Snippet for the config.json:

  "test": {
    "username": "root",
    "password": null,
    "database": "testDB",
    "host": "127.0.0.1",
    "dialect": "mysql",
    "define": { "charset": "utf8", "collate": "utf8_general_ci" }
  },

What do you expect to happen?

Expected collate to change from default running migrations.

What is actually happening?

Got default collate set by sequelize instead.

Create code sent by sequelize-cli:

CREATE TABLE `geolocation` (
	`id` VARCHAR(40) NOT NULL COLLATE 'latin1_swedish_ci',
	`name` VARCHAR(80) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`address` VARCHAR(160) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`email` VARCHAR(160) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`company` VARCHAR(160) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`phone` VARCHAR(160) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`latitude` VARCHAR(32) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`longitude` VARCHAR(32) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
	`coordinates` POINT NULL DEFAULT NULL,
	`createdAt` DATETIME NULL DEFAULT NULL,
	`updatedAt` DATETIME NULL DEFAULT NULL,
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `geolocation_coordinates_address` (`coordinates`(25), `address`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;

Dialect: mysql
Database version: 5.7.24
Sequelize CLI version: Sequelize CLI [Node: 14.16.0, CLI: 6.2.0, ORM: 6.6.2]
Sequelize version: 6.6.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions