From d6565da1975f9006536e7fd14d95921deffd73a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Wed, 25 Sep 2019 13:28:40 +0200 Subject: [PATCH] fix: add public.knex_migrations --- src/utils.js | 4 ++-- test/__fixtures__/structure.sql | 6 +++--- test/utils.test.js | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) 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());`, ]) }) })