Closed confuser closed 2 years ago
Note for others, this is possible by nesting the columns in a columns
property and specifying a charset
property:
await db.createTable('bm_web_appeals', {
columns: {
id: { type: 'int', notNull: true, primaryKey: true, autoIncrement: true },
server_id: {
type: 'string',
notNull: true,
charset: 'utf8',
foreignKey: {
name: 'bm_web_appeals_server_id_fk',
table: 'bm_web_servers',
mapping: 'id',
rules: {
onDelete: 'CASCADE',
onUpdate: 'CASCADE'
}
}
},
actor_id: { type: 'binary', length: 16, notNull: true },
assignee_id: { type: 'binary', length: 16, notNull: true },
punishment_id: { type: 'int', notNull: true },
punishment_type: { type: 'string', notNull: true },
state_id: {
type: 'int',
notNull: true,
foreignKey: {
name: 'bm_web_appeals_state_id_fk',
table: 'bm_web_appeal_states',
mapping: 'id',
rules: {
onDelete: 'RESTRICT',
onUpdate: 'CASCADE'
}
}
},
created: { type: 'int', length: 10, notNull: true },
updated: { type: 'int', length: 10, notNull: true },
reason: { type: 'text', notNull: true }
},
charset: 'utf8'
})
I'm submitting a...
Current behavior
When creating a table using db-migrate's API (db.createTable) it appears it's not possible to specify the default charset.
Scenario: I have a table which I'd like to create a foreign key reference to. This is currently failing as the parent table is set to 'utf8' where as the newly created table via db-migrate is set to latin1
Expected behavior
Allow specifying charset for table creation
Minimal reproduction of the problem with instructions
Existing table:
Migration:
Produces:
Fails with
What is the motivation / use case for changing the behavior?
Environment