UI styling improvements: dashboard headers and navigation
- Restore blue PageHeader on Dashboard (/app-components) - Update homepage (/) with subtle header design without blue bar - Add uniform PageHeader styling to application edit page - Fix Rapporten link on homepage to point to /reports overview - Improve header descriptions spacing for better readability
This commit is contained in:
90
backend/scripts/migrate-search-enabled.ts
Normal file
90
backend/scripts/migrate-search-enabled.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Migration script: Add search_enabled column to schemas table
|
||||
*
|
||||
* This script adds the search_enabled column to the schemas table if it doesn't exist.
|
||||
*
|
||||
* Usage:
|
||||
* npm run migrate:search-enabled
|
||||
* or
|
||||
* tsx scripts/migrate-search-enabled.ts
|
||||
*/
|
||||
|
||||
import { getDatabaseAdapter } from '../src/services/database/singleton.js';
|
||||
import { logger } from '../src/services/logger.js';
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
console.log('Starting migration: Adding search_enabled column to schemas table...');
|
||||
|
||||
const db = getDatabaseAdapter();
|
||||
await db.ensureInitialized?.();
|
||||
|
||||
const isPostgres = db.isPostgres === true;
|
||||
|
||||
// Check if column exists and add it if it doesn't
|
||||
if (isPostgres) {
|
||||
// PostgreSQL: Check if column exists
|
||||
const columnExists = await db.queryOne<{ exists: boolean }>(`
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'schemas' AND column_name = 'search_enabled'
|
||||
) as exists
|
||||
`);
|
||||
|
||||
if (!columnExists?.exists) {
|
||||
console.log('Adding search_enabled column to schemas table...');
|
||||
await db.execute(`
|
||||
ALTER TABLE schemas ADD COLUMN search_enabled BOOLEAN NOT NULL DEFAULT TRUE;
|
||||
`);
|
||||
console.log('✓ Column added successfully');
|
||||
} else {
|
||||
console.log('✓ Column already exists');
|
||||
}
|
||||
|
||||
// Create index if it doesn't exist
|
||||
try {
|
||||
await db.execute(`
|
||||
CREATE INDEX IF NOT EXISTS idx_schemas_search_enabled ON schemas(search_enabled);
|
||||
`);
|
||||
console.log('✓ Index created/verified');
|
||||
} catch (error) {
|
||||
console.log('Index may already exist, continuing...');
|
||||
}
|
||||
} else {
|
||||
// SQLite: Try to query the column to see if it exists
|
||||
try {
|
||||
await db.queryOne('SELECT search_enabled FROM schemas LIMIT 1');
|
||||
console.log('✓ Column already exists');
|
||||
} catch {
|
||||
// Column doesn't exist, add it
|
||||
console.log('Adding search_enabled column to schemas table...');
|
||||
await db.execute('ALTER TABLE schemas ADD COLUMN search_enabled INTEGER NOT NULL DEFAULT 1');
|
||||
console.log('✓ Column added successfully');
|
||||
}
|
||||
|
||||
// Create index if it doesn't exist
|
||||
try {
|
||||
await db.execute('CREATE INDEX IF NOT EXISTS idx_schemas_search_enabled ON schemas(search_enabled)');
|
||||
console.log('✓ Index created/verified');
|
||||
} catch (error) {
|
||||
console.log('Index may already exist, continuing...');
|
||||
}
|
||||
}
|
||||
|
||||
// Verify the column exists
|
||||
try {
|
||||
await db.queryOne('SELECT search_enabled FROM schemas LIMIT 1');
|
||||
console.log('✓ Migration completed successfully - search_enabled column verified');
|
||||
} catch (error) {
|
||||
console.error('✗ Migration verification failed:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('✗ Migration failed:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user