Skip to content

Commit

Permalink
Provide charset and collate options only for dialects supporting them
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinFarizon committed Oct 31, 2023
1 parent e502214 commit ec0f898
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/storage/sequelize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ export type SequelizeType = {
isDefined(modelName: string): boolean;
model(modelName: string): any;
define(modelName: string, columns: {}, options: {}): {};
dialect?: {
name?: string;
};
};

const DIALECTS_WITH_CHARSET_AND_COLLATE = ['mysql', 'mariadb', 'snowflake']

type ModelClassType = ModelClass & (new (values?: object, options?: any) => ModelTempInterface);

type _SequelizeStorageConstructorOptions = {
Expand Down Expand Up @@ -142,8 +147,8 @@ export class SequelizeStorage implements UmzugStorage {
tableName: this.tableName,
schema: this.schema,
timestamps: this.timestamps,
charset: 'utf8',
collate: 'utf8_unicode_ci',
charset: DIALECTS_WITH_CHARSET_AND_COLLATE.includes(this.sequelize.dialect!.name!) ? 'utf8' : null,
collate: DIALECTS_WITH_CHARSET_AND_COLLATE.includes(this.sequelize.dialect!.name!) ? 'utf8_unicode_ci' : null,
}
) as ModelClassType;
}
Expand Down

0 comments on commit ec0f898

Please sign in to comment.