Skip to content

Commit

Permalink
Merge pull request #104 from ethanlaj/feat/sql-server
Browse files Browse the repository at this point in the history
a
  • Loading branch information
ethanlaj authored Apr 16, 2024
2 parents 249b82d + d9b8ed9 commit c6550fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
10 changes: 6 additions & 4 deletions api/src/database/scripts/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ async function markMigrationsAsExecuted() {

for (const file of migrationFiles) {
await sequelize.query(
'CREATE TABLE IF NOT EXISTS SequelizeMeta (name VARCHAR(255) NOT NULL, PRIMARY KEY (name));'
'IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = \'dbo\' AND TABLE_NAME = \'SequelizeMeta\') ' +
'CREATE TABLE SequelizeMeta (name VARCHAR(255) NOT NULL PRIMARY KEY);'
);
await sequelize.query(
'INSERT IGNORE INTO SequelizeMeta (name) VALUES (?);',
'IF NOT EXISTS (SELECT * FROM SequelizeMeta WHERE name = :file) ' +
'INSERT INTO SequelizeMeta (name) VALUES (:file);',
{
replacements: [file],
replacements: { file: file }
}
);
}
}
}

sequelize
Expand Down

0 comments on commit c6550fd

Please sign in to comment.