-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(sandbox): refactor feature toggle example sandbox (#2236)
* refactor(feature-toggle): refactor code refactor code MIGRATION CHANGE: migration-20230612141912- refactor code migration-20210913104858- refactor code 0 * refactor(feature-toggle): lint issues lint issues 0 lint issues
- Loading branch information
1 parent
f5fc1e1
commit 20257a1
Showing
7 changed files
with
186 additions
and
31 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
59 changes: 59 additions & 0 deletions
59
sandbox/feature-toggle-example/migrations/20230612141912-update-tables.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,59 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function (db) { | ||
var filePath = path.join( | ||
__dirname, | ||
'sqls', | ||
'20230612141912-update-tables-up.sql', | ||
); | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) { | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}).then(function (data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function (db) { | ||
var filePath = path.join( | ||
__dirname, | ||
'sqls', | ||
'20230612141912-update-tables-down.sql', | ||
); | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) { | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}).then(function (data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
version: 1, | ||
}; |
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
28 changes: 28 additions & 0 deletions
28
sandbox/feature-toggle-example/migrations/sqls/20230612141912-update-tables-down.sql
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,28 @@ | ||
ALTER TABLE main.features | ||
drop column metadata, | ||
drop column created_by, | ||
drop column modified_by , | ||
drop column created_on , | ||
drop column modified_on | ||
drop column deleted , | ||
drop column deleted_on , | ||
drop column deleted_by; | ||
|
||
|
||
ALTER TABLE main.strategies | ||
drop column created_by, | ||
drop column modified_by , | ||
drop column created_on , | ||
drop column modified_on | ||
drop column deleted , | ||
drop column deleted_on , | ||
drop column deleted_by; | ||
|
||
ALTER TABLE main.feature_values | ||
drop column created_by, | ||
drop column modified_by , | ||
drop column created_on , | ||
drop column modified_on | ||
drop column deleted , | ||
drop column deleted_on , | ||
drop column deleted_by; |
29 changes: 29 additions & 0 deletions
29
sandbox/feature-toggle-example/migrations/sqls/20230612141912-update-tables-up.sql
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,29 @@ | ||
/* Replace with your SQL commands */ | ||
|
||
ALTER TABLE main.features | ||
ADD metadata TEXT, | ||
ADD created_by varchar(100), | ||
ADD modified_by varchar(100), | ||
ADD created_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
ADD modified_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
ADD deleted bool DEFAULT false NOT NULL , | ||
ADD deleted_on timestamptz , | ||
ADD deleted_by uuid ; | ||
|
||
ALTER TABLE main.strategies | ||
ADD created_by varchar(100), | ||
ADD modified_by varchar(100), | ||
ADD created_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
ADD modified_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
ADD deleted bool DEFAULT false NOT NULL , | ||
ADD deleted_on timestamptz , | ||
ADD deleted_by uuid ; | ||
|
||
ALTER TABLE main.feature_values | ||
ADD created_by varchar(100), | ||
ADD modified_by varchar(100), | ||
ADD created_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
ADD modified_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
ADD deleted bool DEFAULT false NOT NULL , | ||
ADD deleted_on timestamptz , | ||
ADD deleted_by uuid ; |
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