Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Remove undefined as default value for namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
lsilvs committed May 28, 2019
1 parent 4d7c893 commit f9cd530
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions framework/src/controller/migrations/sql/define_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ CREATE TABLE IF NOT EXISTS "migrations"(
);

-- Add new column `namespace` to identify migration's groups
ALTER TABLE "migrations" ADD COLUMN IF NOT EXISTS "namespace" TEXT NOT NULL DEFAULT 'undefined';

-- Make `namespace` column composite primary key along with `id`
ALTER TABLE "migrations" DROP CONSTRAINT IF EXISTS "migrations_pkey";
ALTER TABLE "migrations" ADD CONSTRAINT "migrations_pkey" PRIMARY KEY ("id", "namespace");
ALTER TABLE "migrations" ADD COLUMN IF NOT EXISTS "namespace" TEXT;

-- Remove framework-related migration (20180205000000_underscore_patch.sql)
DELETE FROM "migrations" WHERE id = '20180205000000' AND name = 'underscore_patch';

-- Populate `namespace` with correct initial values when it exists
UPDATE "migrations" SET namespace = 'network' WHERE namespace = 'undefined' AND id IN ('20161016133824', '20170113181857', '20171207000001', '20171227155620', '20180205000002', '20180327170000', '20181106000006', '20190103000001', '20190111111557');
UPDATE "migrations" SET namespace = 'chain' WHERE namespace = 'undefined';
UPDATE "migrations" SET namespace = 'network' WHERE namespace IS NULL AND id IN ('20161016133824', '20170113181857', '20171207000001', '20171227155620', '20180205000002', '20180327170000', '20181106000006', '20190103000001', '20190111111557');
UPDATE "migrations" SET namespace = 'chain' WHERE namespace IS NULL;

-- Make `namespace` column composite primary key along with `id`
ALTER TABLE "migrations" DROP CONSTRAINT IF EXISTS "migrations_pkey";
ALTER TABLE "migrations" ADD CONSTRAINT "migrations_pkey" PRIMARY KEY ("id", "namespace");

-- Duplicate 20160723182900_create_schema.sql migration for `network` module if migration exists for `chain` module
-- That is required because 20160723182900_create_schema.sql was splited into two different files (one for each module)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ describe('Migration', () => {
validMigration = {
id: '30200723182900',
name: 'create_schema',
namespace: 'module_name',
};

adapter = storage.adapter;
Expand Down

0 comments on commit f9cd530

Please sign in to comment.