Skip to content

Commit

Permalink
Fix migrations test
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyding committed Jan 8, 2025
1 parent 29bed1e commit 567b7c7
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions indexer/packages/postgres/__tests__/db/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
} from '../helpers/constants';
import { seedData } from '../helpers/mock-generators';

// NOTE: If a model is modified for a migration then these
// tests must be skipped until the following migration
describe('Test new migration', () => {
beforeEach(async () => {
await migrate();
Expand All @@ -25,29 +23,44 @@ describe('Test new migration', () => {
await teardown();
});

it('test adding most recent migration', async () => {
it('test UP and DOWN for most recent migration without seed data', async () => {
// remove latest migration
await multiDown(1);

// re-add latest migration
await knexPrimary.migrate.latest({ loadExtensions: ['.js'] });

// re-remove latest migration
await multiDown(1);
});

// NOTE: If a model is modified for a migration then these
// tests must be skipped until the following migration
it.skip('[Will fail if a model is modified for migration - see README] test adding most recent migration', async () => {
// remove latest migration
await multiDown(1);

// add data to verify you can roll up and then later roll down
await seedData();

// readd latest migration
// re-add latest migration
await knexPrimary.migrate.latest({ loadExtensions: ['.js'] });

// re-remove latest migration
await multiDown(1);
});

it('test adding most recent migration with rows that fail index that should only be applied going forward', async () => {
// NOTE: If a model is modified for a migration then these
// tests must be skipped until the following migration
it.skip('[Will fail if a model is modified for migration - see README] test adding most recent migration with rows that fail index that should only be applied going forward', async () => {
// remove latest migration
await multiDown(1);

// add data to verify you can roll up and then later roll down
await seedData();
await OrderTable.create(defaultOrder);

// readd latest migration
// re-add latest migration
await knexPrimary.migrate.latest({ loadExtensions: ['.js'] });

// re-remove latest migration
Expand Down

0 comments on commit 567b7c7

Please sign in to comment.