-
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.
- Loading branch information
Showing
57 changed files
with
27,217 additions
and
5,547 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
dist/ | ||
coverage/ | ||
migrations/ | ||
.eslintrc.js |
51 changes: 51 additions & 0 deletions
51
sandbox/search-ms-example/migrations/20211003143854-init.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,51 @@ | ||
'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', '20211003143854-init-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', '20211003143854-init-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"defaultEnv": "master", | ||
"master": { | ||
"driver": "pg", | ||
"host": { | ||
"ENV": "DB_HOST" | ||
}, | ||
"port": { | ||
"ENV": "DB_PORT" | ||
}, | ||
"user": { | ||
"ENV": "DB_USER" | ||
}, | ||
"password": { | ||
"ENV": "DB_PASSWORD" | ||
}, | ||
"database": { | ||
"ENV": "DB_DATABASE" | ||
} | ||
}, | ||
"sql-file": true | ||
} | ||
|
2 changes: 2 additions & 0 deletions
2
sandbox/search-ms-example/migrations/sqls/20211003143854-init-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,2 @@ | ||
drop table main.recent_search; | ||
drop table main.search_query; |
52 changes: 52 additions & 0 deletions
52
sandbox/search-ms-example/migrations/sqls/20211003143854-init-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,52 @@ | ||
CREATE SCHEMA IF NOT EXISTS main; | ||
|
||
SET search_path TO main,public; | ||
GRANT ALL ON SCHEMA main TO public; | ||
|
||
CREATE TABLE main.recent_search ( | ||
id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL , | ||
user_id uuid NOT NULL, | ||
created_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
modified_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
created_by uuid , | ||
modified_by uuid , | ||
deleted bool DEFAULT false NOT NULL , | ||
deleted_on timestamptz , | ||
deleted_by uuid , | ||
CONSTRAINT recent_search_pkey PRIMARY KEY (id) | ||
); | ||
|
||
CREATE TABLE main.search_query ( | ||
id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL , | ||
created_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
modified_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL , | ||
created_by uuid , | ||
modified_by uuid , | ||
deleted bool DEFAULT false NOT NULL , | ||
deleted_on timestamptz , | ||
deleted_by uuid , | ||
match text NOT NULL, | ||
"limit" integer NULL, | ||
"order" varchar(100) NULL, | ||
limit_by_type boolean NULL, | ||
"offset" integer NULL, | ||
sources json NULL, | ||
recent_search_id uuid, | ||
CONSTRAINT search_query_pk PRIMARY KEY (id) | ||
); | ||
|
||
CREATE TABLE main.todo ( | ||
id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL , | ||
name text NOT NULL, | ||
description text NOT NULL, | ||
CONSTRAINT todo_pkey PRIMARY KEY (id) | ||
); | ||
|
||
CREATE TABLE main.user ( | ||
id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL , | ||
username text NOT NULL, | ||
about text NOT NULL, | ||
CONSTRAINT user_pkey PRIMARY KEY (id) | ||
); | ||
|
||
ALTER TABLE main.search_query ADD CONSTRAINT fk_recent_search_in_query FOREIGN KEY ( recent_search_id ) REFERENCES main.recent_search( id ); |
Oops, something went wrong.