Added check to war user if some migrations are not yet applied
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { execSync } from 'node:child_process';
|
import { execSync } from 'node:child_process';
|
||||||
|
import { checkPendingMigrations } from './migrations.mjs';
|
||||||
|
|
||||||
function runGitCommand(command) {
|
function runGitCommand(command) {
|
||||||
try {
|
try {
|
||||||
@@ -52,4 +53,5 @@ function checkMakerkitVersion() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMakerkitVersion();
|
checkMakerkitVersion();
|
||||||
|
checkPendingMigrations();
|
||||||
30
tooling/version/src/migrations.mjs
Normal file
30
tooling/version/src/migrations.mjs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { execSync } from 'node:child_process';
|
||||||
|
|
||||||
|
export function checkPendingMigrations() {
|
||||||
|
try {
|
||||||
|
console.log('\nChecking for pending migrations...');
|
||||||
|
|
||||||
|
const output = execSync('pnpm --filter web supabase migration list', { encoding: 'utf-8', stdio: 'pipe' });
|
||||||
|
const lines = output.split('\n');
|
||||||
|
|
||||||
|
// Skip header lines
|
||||||
|
const migrationLines = lines.slice(4);
|
||||||
|
|
||||||
|
const pendingMigrations = migrationLines
|
||||||
|
.filter(line => {
|
||||||
|
const [local, remote] = line.split('│').map(s => s.trim());
|
||||||
|
return local !== '' && remote === '';
|
||||||
|
})
|
||||||
|
.map(line => (line.split('│')[0] ?? '').trim());
|
||||||
|
|
||||||
|
if (pendingMigrations.length > 0) {
|
||||||
|
console.log('\x1b[33m%s\x1b[0m', '⚠️ There are pending migrations that need to be applied:');
|
||||||
|
pendingMigrations.forEach(migration => console.log(` - ${migration}`));
|
||||||
|
console.log('\nPlease run "pnpm --filter web supabase db push" to apply these migrations.');
|
||||||
|
} else {
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', '✅ All migrations are up to date.');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('\x1b[33m%s\x1b[0m', '⚠️ No remote Supabase project found. You may not yet have linked your Supabase project. Feel free to ignore this message.');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user