diff --git a/src/utils.js b/src/utils.js index 9cadd17..5b24503 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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 = [] diff --git a/test/__fixtures__/structure.sql b/test/__fixtures__/structure.sql index 77337b6..7cbddbf 100644 --- a/test/__fixtures__/structure.sql +++ b/test/__fixtures__/structure.sql @@ -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()); diff --git a/test/utils.test.js b/test/utils.test.js index ddc563b..622045a 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -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());`, ]) }) }) @@ -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());`, ]) }) })