diff --git a/shared/database/src/migrations/migration_script.mjs b/shared/database/src/migrations/migration_script.mjs index 7ec301c..098765b 100644 --- a/shared/database/src/migrations/migration_script.mjs +++ b/shared/database/src/migrations/migration_script.mjs @@ -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!')); diff --git a/tests/unit/database/migration-script-path.test.ts b/tests/unit/database/migration-script-path.test.ts new file mode 100644 index 0000000..6a63a30 --- /dev/null +++ b/tests/unit/database/migration-script-path.test.ts @@ -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); + }); +});