Skip to content

Commit

Permalink
fix: add public.knex_migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Sep 25, 2019
1 parent 1c91b4b commit d6565da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ export async function getInsertsFromMigrations(migrationsPath) {
const migrations = await readdir(migrationsPath)
return migrations.map(
migration =>
`INSERT INTO knex_migrations(name, batch, migration_time) VALUES ('${migration}', 1, NOW());`,
`INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('${migration}', 1, NOW());`,
)
}

export async function getInsertsFromStructure(structurePath) {
if (!(await exists(structurePath))) return []
const structure = await readFile(structurePath, 'utf-8')
const regExp = /INSERT INTO knex_migrations\(name, batch, migration_time\) VALUES \('.*', 1, NOW\(\)\);/g
const regExp = /INSERT INTO public\.knex_migrations\(name, batch, migration_time\) VALUES \('.*', 1, NOW\(\)\);/g

const inserts = []

Expand Down
6 changes: 3 additions & 3 deletions test/__fixtures__/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;

-- Knex migrations

INSERT INTO knex_migrations(name, batch, migration_time) VALUES ('20180207153033_migration_1.js', 1, NOW());
INSERT INTO knex_migrations(name, batch, migration_time) VALUES ('20180207153040_migration_2.js', 1, NOW());
INSERT INTO knex_migrations(name, batch, migration_time) VALUES ('20180207153050_migration_3.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20180207153033_migration_1.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20180207153040_migration_2.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20180207153050_migration_3.js', 1, NOW());
10 changes: 5 additions & 5 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ describe('#getInsertsFromMigrations', () => {
path.join(__dirname, '__fixtures__/migrations'),
)
expect(inserts).toEqual([
`INSERT INTO knex_migrations(name, batch, migration_time) VALUES ('20180207153033_migration_1.js', 1, NOW());`,
`INSERT INTO knex_migrations(name, batch, migration_time) VALUES ('20180207153040_migration_2.js', 1, NOW());`,
`INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20180207153033_migration_1.js', 1, NOW());`,
`INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20180207153040_migration_2.js', 1, NOW());`,
])
})
})
Expand All @@ -33,9 +33,9 @@ describe('#getInsertsFromStructure', () => {
path.join(__dirname, '__fixtures__/structure.sql'),
)
expect(inserts).toEqual([
`INSERT INTO knex_migrations(name, batch, migration_time) VALUES ('20180207153033_migration_1.js', 1, NOW());`,
`INSERT INTO knex_migrations(name, batch, migration_time) VALUES ('20180207153040_migration_2.js', 1, NOW());`,
`INSERT INTO knex_migrations(name, batch, migration_time) VALUES ('20180207153050_migration_3.js', 1, NOW());`,
`INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20180207153033_migration_1.js', 1, NOW());`,
`INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20180207153040_migration_2.js', 1, NOW());`,
`INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20180207153050_migration_3.js', 1, NOW());`,
])
})
})

0 comments on commit d6565da

Please sign in to comment.