Skip to content

Commit

Permalink
Merge branch 'master' into search
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatdubeysf committed Oct 20, 2021
2 parents c3de9d9 + 6912bc2 commit 7064e21
Show file tree
Hide file tree
Showing 57 changed files with 27,217 additions and 5,547 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/enums/status-codes.enum.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable-next-line @typescript-eslint/naming-convention */
/**
* List of all the HttpStatus codes
* @link https://httpstatuses.com/
*/
/* eslint-disable-next-line @typescript-eslint/naming-convention */
export const enum STATUS_CODE {
// sonarignore:start
CONTINUE = 100,
Expand Down
1 change: 1 addition & 0 deletions sandbox/search-ms-example/.eslintignore
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 sandbox/search-ms-example/migrations/20211003143854-init.js
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,
};
23 changes: 23 additions & 0 deletions sandbox/search-ms-example/migrations/database.json
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
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
drop table main.recent_search;
drop table main.search_query;
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 );
Loading

0 comments on commit 7064e21

Please sign in to comment.