This repository has been archived by the owner on Dec 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from ONSdigital/402-properties-decimals
Add properties to answers
- Loading branch information
Showing
15 changed files
with
294 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
exports.up = function(knex) { | ||
return knex.schema.table("Answers", table => { | ||
table | ||
.jsonb("properties") | ||
.defaultsTo("{}") | ||
.notNullable(); | ||
}); | ||
}; | ||
|
||
exports.down = function(knex) { | ||
return knex.schema.table("Answers", table => { | ||
table.dropColumn("properties"); | ||
}); | ||
}; |
15 changes: 15 additions & 0 deletions
15
migrations/20180622154505_migrate_mandatory_field_data_to_properties.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
exports.up = function(knex) { | ||
return knex.schema.raw(` | ||
UPDATE "Answers" | ||
SET properties = json_build_object( | ||
'required', mandatory | ||
)::jsonb; | ||
`); | ||
}; | ||
|
||
exports.down = function(knex) { | ||
return knex.schema.raw(` | ||
UPDATE "Answers" | ||
SET mandatory = (properties->>'required')::boolean | ||
`); | ||
}; |
14 changes: 14 additions & 0 deletions
14
migrations/20180622160307_remove_mandatory_from_answers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
exports.up = function(knex) { | ||
return knex.schema.table("Answers", function(table) { | ||
table.dropColumn("mandatory"); | ||
}); | ||
}; | ||
|
||
exports.down = function(knex) { | ||
return knex.schema.table("Answers", function(table) { | ||
table | ||
.boolean("mandatory") | ||
.notNullable() | ||
.defaultsTo(false); | ||
}); | ||
}; |
20 changes: 20 additions & 0 deletions
20
migrations/20180706134843_add_decimals_data_to_properties.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
exports.up = function(knex) { | ||
return knex.schema.raw(` | ||
UPDATE "Answers" | ||
SET properties = json_build_object( | ||
'required', (properties->>'required')::boolean, | ||
'decimals', 0 | ||
)::jsonb | ||
WHERE type IN ('Number', 'Currency'); | ||
`); | ||
}; | ||
|
||
exports.down = function(knex) { | ||
return knex.schema.raw(` | ||
UPDATE "Answers" | ||
SET properties = json_build_object( | ||
'required', (properties->>'required')::boolean | ||
)::jsonb | ||
WHERE type IN ('Number', 'Currency'); | ||
`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.