Skip to content

Commit

Permalink
fix(migrate): sql server database creation if needed (#8669)
Browse files Browse the repository at this point in the history
Closes #8058
  • Loading branch information
Jolg42 committed Aug 10, 2021
1 parent bf92279 commit 866cf2d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/migrate/src/utils/ensureDatabaseExists.ts
Expand Up @@ -27,7 +27,7 @@ export async function getDbInfo(schemaPath?: string): Promise<{
const activeDatasource = config.datasources[0]
const url = activeDatasource.url.value

if (url.startsWith('sqlserver') || url.startsWith('jdbc:sqlserver')) {
if (activeDatasource.provider === 'sqlserver') {
return {
name: activeDatasource.name,
schemaWord: 'database',
Expand Down Expand Up @@ -135,6 +135,11 @@ export async function ensureDatabaseExists(
}
if (forceCreate) {
if (await createDatabase(activeDatasource.url.value, schemaDir)) {
// URI parsing is not implemented for SQL server yet
if (activeDatasource.provider === 'sqlserver') {
return `SQL Server database created.\n`
}

const credentials = uriToCredentials(activeDatasource.url.value)
const { schemaWord, dbType, dbName } =
getDbinfoFromCredentials(credentials)
Expand Down

0 comments on commit 866cf2d

Please sign in to comment.