Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared/database/src/migrations/migration_script.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ const migrationClient = postgres(

const db = drizzle(migrationClient);

migrate(db, { migrationsFolder: 'src/db/migrations' })
migrate(db, { migrationsFolder: 'shared/database/src/migrations' })
.catch((e) => console.error(e))
.then(() => console.log('MIGRATION COMPLETE!'));
23 changes: 23 additions & 0 deletions tests/unit/database/migration-script-path.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as fs from 'fs';
import * as path from 'path';

const MIGRATION_SCRIPT_PATH = path.resolve(__dirname, '../../../shared/database/src/migrations/migration_script.mjs');

const EXPECTED_MIGRATIONS_FOLDER = 'shared/database/src/migrations';

describe('migration_script.mjs', () => {
it('should reference the correct migrations folder path', () => {
const content = fs.readFileSync(MIGRATION_SCRIPT_PATH, 'utf-8');
const match = content.match(/migrationsFolder:\s*['"]([^'"]+)['"]/);
expect(match).not.toBeNull();

const migrationsFolder = match[1];
expect(migrationsFolder).toBe(EXPECTED_MIGRATIONS_FOLDER);
});

it('should point to a directory that exists relative to the workspace root', () => {
const workspaceRoot = path.resolve(__dirname, '../../..');
const resolvedPath = path.resolve(workspaceRoot, EXPECTED_MIGRATIONS_FOLDER);
expect(fs.existsSync(resolvedPath)).toBe(true);
});
});
Loading