-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run database setup via migration scripts
- Loading branch information
1 parent
f4f327f
commit 3df1200
Showing
23 changed files
with
6,326 additions
and
858 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
exports.shorthands = undefined; | ||
|
||
//@TODO: Run these migrations from postgres account separately | ||
exports.up = (pgm) => { | ||
// pgm.noTransaction(); | ||
// pgm.sql("SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'boda';"); | ||
// pgm.sql("DROP DATABASE IF EXISTS boda"); | ||
// | ||
// pgm.createRole( "bodastage", { | ||
// "password": "password", | ||
// "login": true | ||
// } ); | ||
// | ||
// pgm.sql( "CREATE DATABASE boda owner bodastage"); | ||
|
||
}; | ||
|
||
exports.down = (pgm) => { | ||
// pgm.noTransaction(); | ||
// pgm.sql("DROP DATABASE IF EXISTS boda"); | ||
// pgm.dropRole("bodastage"); | ||
|
||
}; |
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,62 @@ | ||
exports.shorthands = undefined; | ||
const hexToIntParams = [ | ||
{mode: 'in', name: "hexval", type: "varchar"} | ||
]; | ||
|
||
exports.up = (pgm) => { | ||
//Create hex to int function | ||
pgm.createFunction( | ||
//name | ||
"hex_to_int", | ||
|
||
//function_params | ||
hexToIntParams, | ||
|
||
//function_options | ||
{ | ||
returns: "integer", | ||
language: "plpgsql" | ||
}, | ||
|
||
//definiton | ||
` | ||
DECLARE | ||
result int; | ||
BEGIN | ||
EXECUTE 'SELECT x''' || hexval || '''::int' INTO result; | ||
RETURN result; | ||
END; | ||
` | ||
); | ||
|
||
//Create hex to char function | ||
pgm.createFunction( | ||
//name | ||
"hex_to_char", | ||
|
||
//function_params | ||
hexToIntParams, | ||
|
||
//function_options | ||
{ | ||
returns: "varchar", | ||
language: "plpgsql" | ||
}, | ||
|
||
//definiton | ||
` | ||
DECLARE | ||
result varchar; | ||
BEGIN | ||
EXECUTE 'SELECT x''' || hexval || '''::int' INTO result; | ||
RETURN result; | ||
END; | ||
` | ||
); | ||
|
||
}; | ||
|
||
exports.down = (pgm) => { | ||
pgm.dropFunction("hex_to_int", hexToIntParams); | ||
pgm.dropFunction("hex_to_char", hexToIntParams); | ||
}; |
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.shorthands = undefined; | ||
|
||
exports.up = (pgm) => { | ||
pgm.createSchema("ericsson_cm", {ifNotExists : true} ); | ||
pgm.createSchema("huawei_cm", {ifNotExists : true} ); | ||
pgm.createSchema("zte_cm", {ifNotExists : true} ); | ||
pgm.createSchema("nokia_cm", {ifNotExists : true} ); | ||
}; | ||
|
||
exports.down = (pgm) => { | ||
pgm.dropSchema("ericsson_cm", {ifExists : true} ); | ||
pgm.dropSchema("huawei_cm", {ifExists : true} ); | ||
pgm.dropSchema("zte_cm", {ifExists : true} ); | ||
pgm.dropSchema("nokia_cm", {ifExists : true} ); | ||
}; |
50 changes: 50 additions & 0 deletions
50
db/migrations/1564264136564_create-ericssom-cm-cnaiv2-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,50 @@ | ||
const PgLiteral = window.require('node-pg-migrate').PgLiteral; | ||
|
||
exports.shorthands = { | ||
idx: { type: 'uuid', primaryKey: true}, | ||
load_datetime: { | ||
type: "timestamp", | ||
notNull: true, | ||
default: new PgLiteral('current_timestamp') | ||
}, | ||
data: {type: "jsonb", notNull: true}, | ||
createdAt: { | ||
type: "timestamp", | ||
notNull: true, | ||
default: new PgLiteral('current_timestamp') | ||
} | ||
}; | ||
|
||
exports.up = (pgm) => { | ||
pgm.createTable({schema: "ericsson_cm", name: "UTRAN_NREL"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "UTRAN_EXTERNAL_CELL"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "TG"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "SITE"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "PRIORITY_PROFILE"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "OVERLAID_CELL"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "OUTER_CELL"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "NREL"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "MSC"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "INTERNAL_CELL"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "INNER_CELL"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "EXTERNAL_CELL"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "CHANNEL_GROUP"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
pgm.createTable({schema: "ericsson_cm", name: "BSC"}, {id: "id", load_datetime: "load_datetime", data: "data"}); | ||
}; | ||
|
||
exports.down = (pgm) => { | ||
pgm.dropTable({schema: "ericsson_cm", name: 'UTRAN_NREL'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'UTRAN_EXTERNAL_CELL'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'TG'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'SITE'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'PRIORITY_PROFILE'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'OVERLAID_CELL'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'OUTER_CELL'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'NREL'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'MSC'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'INTERNAL_CELL'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'INNER_CELL'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'EXTERNAL_CELL'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'CHANNEL_GROUP'}); | ||
pgm.dropTable({schema: "ericsson_cm", name: 'BSC'}); | ||
}; |
Oops, something went wrong.