存档当前项目

This commit is contained in:
2026-06-07 20:39:36 +08:00
parent 1b89ce6f71
commit 7b60136488
17 changed files with 15 additions and 62 deletions
+15 -3
View File
@@ -28,6 +28,11 @@ function loadRootEnv() {
}
}
function getMigrationVersion(file) {
const match = file.match(/^(\d+)_/);
return match ? match[1] : file;
}
async function main() {
loadRootEnv();
@@ -50,9 +55,16 @@ async function main() {
`);
for (const file of files) {
const version = getMigrationVersion(file);
const [rows] = await connection.query(
'SELECT version FROM schema_migrations WHERE version = ?',
[file],
`
SELECT version
FROM schema_migrations
WHERE version = ?
OR version = ?
OR version LIKE ?
`,
[version, file, `${version}\\_%`],
);
if (rows.length > 0) {
console.log(`skip ${file}`);
@@ -70,7 +82,7 @@ async function main() {
}
await connection.query(
'INSERT INTO schema_migrations (version) VALUES (?)',
[file],
[version],
);
await connection.commit();
console.log(`applied ${file}`);