Commit 368daa91 authored by Abdul R. Wahid's avatar Abdul R. Wahid
Browse files

Merge branch 'develop' into 'master'

Migration enum compability on mysql improve

See merge request riset/onest!32
parents 7fff8276 b316d276
......@@ -41,21 +41,35 @@ const formatAlterMysqlTableEnumSql = (
}
export async function up (knex: Knex): Promise<any> {
let sql = formatAlterTableEnumSql('verifications', 'verify_type', VERIFICATION_ENUM_NEW)
if (knex.client.config.client === 'mysql') {
sql = formatAlterMysqlTableEnumSql('verifications', 'verify_type', VERIFICATION_ENUM_NEW)
return knex.schema
.table('verifications', function (table) {
table.enum('verify_type', VERIFICATION_ENUM_NEW).notNullable().alter()
})
.then(() => knex.schema.raw(
formatAlterMysqlTableEnumSql('verifications', 'verify_type', VERIFICATION_ENUM_NEW)
)
)
} else {
return knex.schema
.raw(formatAlterTableEnumSql('verifications', 'verify_type', VERIFICATION_ENUM_NEW))
}
return knex.schema
.raw(sql)
}
export async function down (knex: Knex): Promise<any> {
let sql = formatAlterTableEnumSql('verifications', 'verify_type', VERIFICATION_ENUM)
if (knex.client.config.client === 'mysql') {
sql = formatAlterMysqlTableEnumSql('verifications', 'verify_type', VERIFICATION_ENUM)
return knex.schema
.table('verifications', function (table) {
table.enum('verify_type', VERIFICATION_ENUM).notNullable().alter()
})
.then(() => knex.schema.raw(
formatAlterMysqlTableEnumSql('verifications', 'verify_type', VERIFICATION_ENUM)
)
)
} else {
return knex.schema
.raw(formatAlterTableEnumSql('verifications', 'verify_type', VERIFICATION_ENUM))
}
return knex.schema
.raw(sql)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment