generated from Greenstand/treetracker-microservice-template
-
Notifications
You must be signed in to change notification settings - Fork 6
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
21 changed files
with
1,607 additions
and
51 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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
exports.connectionString = process.env.DATABASE_URL; | ||
<<<<<<< HEAD | ||
exports.sentryDSN = ''; | ||
======= | ||
exports.sentryDSN = ''; | ||
>>>>>>> feat: creating tables and queries |
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,5 @@ | ||
const environment = process.env.NODE_ENV || 'development'; | ||
const config = require('../knexfile')[environment]; | ||
const knex = require('knex')(config); | ||
|
||
module.exports = knex; |
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,19 @@ | ||
exports.up = function (knex) { | ||
return knex.schema.createTable('stakeholder', (table) => { | ||
table.uuid('id').primary(); | ||
table.string('type').notNullable(); | ||
table.string('logo').notNullable(); | ||
table.string('name'); | ||
table.string('map').notNullable(); | ||
table.string('email'); | ||
table.string('phone'); | ||
table.string('website').notNullable(); | ||
table.string('children').notNullable(); | ||
table.string('parents').notNullable(); | ||
table.string('users').notNullable(); | ||
}); | ||
}; | ||
|
||
exports.down = function (knex) { | ||
return knex.schema.dropTable('stakeholder'); | ||
}; |
16 changes: 16 additions & 0 deletions
16
database/migrations/20211121004552_createStakeholder_Relations.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,16 @@ | ||
exports.up = function (knex) { | ||
return knex.schema.createTable('stakeholder_relations', (table) => { | ||
table.uuid('org_id').notNullable(); | ||
table | ||
.enu('relation_type', ['parent', 'child'], { | ||
useNative: true, | ||
enumName: 'relation', | ||
}) | ||
.notNullable(); | ||
table.uuid('relation_id').notNullable(); | ||
}); | ||
}; | ||
|
||
exports.down = function (knex) { | ||
return knex.schema.dropTable('stakeholder_relations'); | ||
}; |
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,109 @@ | ||
exports.seed = function (knex) { | ||
// Deletes ALL existing entries | ||
return knex('stakeholder') | ||
.del() | ||
.then(function () { | ||
// Inserts seed entries | ||
return knex('stakeholder').insert([ | ||
{ | ||
type: 'org', | ||
logo_url: './logo_192x192.png', | ||
first_name: '', | ||
last_name: '', | ||
stakeholder_uuid: '', | ||
org_name: 'Greenstand', | ||
id: '792a4eee-8e18-4750-a56f-91bdec383aa6', | ||
map_name: '/greenstandMap', | ||
email: 'hello@greenstand.com', | ||
phone: '123-123-2122', | ||
website: 'greenstand.org', | ||
children: JSON.stringify([ | ||
'1a05ec87-3c38-4395-b9f3-aa15becedc31', | ||
'1d2fb06e-e8f7-40de-8e13-ed3eba1abb3a', | ||
]), | ||
parents: [], | ||
users: [], | ||
}, | ||
{ | ||
type: 'org', | ||
logo_url: './logo_192x192.png', | ||
first_name: '', | ||
last_name: '', | ||
stakeholder_uuid: '', | ||
org_name: 'Greenstance', | ||
id: 'a8567323-88b1-4870-8c48-68d2da3ab356', | ||
map_name: '/greenstance', | ||
email: 'hello@greenstance.com', | ||
phone: '123-123-1234', | ||
website: 'greenstance.com', | ||
children: [], | ||
parents: [], | ||
users: [], | ||
}, | ||
{ | ||
type: 'org', | ||
logo_url: './logo_192x192.png', | ||
first_name: '', | ||
last_name: '', | ||
stakeholder_uuid: '', | ||
org_name: 'Green Space', | ||
id: 'c92189d2-2d55-44bc-a0b4-0dad25dc9f35', | ||
map_name: '/greenspace', | ||
email: 'greenspace@green.com', | ||
phone: '123-123-1324', | ||
website: 'greenspace.com', | ||
children: [], | ||
parents: [], | ||
users: [], | ||
}, | ||
{ | ||
type: 'org', | ||
logo_url: './logo_192x192.png', | ||
first_name: '', | ||
last_name: '', | ||
stakeholder_uuid: '', | ||
org_name: 'Green World', | ||
id: '344a6130-9094-4a05-8fd6-faf176593fbc', | ||
map_name: '/greenworld', | ||
email: 'hi@greenworld.com', | ||
phone: '123-123-1234', | ||
website: 'greenworld.com', | ||
children: [], | ||
parents: [], | ||
users: [], | ||
}, | ||
{ | ||
type: 'person', | ||
logo_url: './logo_192x192.png', | ||
first_name: '', | ||
last_name: '', | ||
stakeholder_uuid: '', | ||
org_name: 'Child One', | ||
id: '1a05ec87-3c38-4395-b9f3-aa15becedc31', | ||
map_name: '/childOne', | ||
email: 'child@gmail.com', | ||
phone: '123-123-1234', | ||
website: 'childone.com', | ||
children: [], | ||
parents: JSON.stringify(['792a4eee-8e18-4750-a56f-91bdec383aa6']), | ||
users: JSON.stringify(['1234']), | ||
}, | ||
{ | ||
type: 'person', | ||
logo_url: './logo_192x192.png', | ||
first_name: '', | ||
last_name: '', | ||
stakeholder_uuid: '', | ||
org_name: 'Child Two', | ||
id: '1d2fb06e-e8f7-40de-8e13-ed3eba1abb3a', | ||
map_name: '/childtwo', | ||
email: 'childtwo@gmail.com', | ||
phone: '123-234-1234', | ||
website: 'childtwo.com', | ||
children: [], | ||
parents: JSON.stringify(['792a4eee-8e18-4750-a56f-91bdec383aa6']), | ||
users: JSON.stringify(['1235']), | ||
}, | ||
]); | ||
}); | ||
}; |
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,30 @@ | ||
exports.seed = function (knex) { | ||
// Deletes ALL existing entries | ||
return knex('stakeholder_relations') | ||
.del() | ||
.then(function () { | ||
// Inserts seed entries | ||
return knex('stakeholder_relations').insert([ | ||
{ | ||
org_id: '792a4eee-8e18-4750-a56f-91bdec383aa6', | ||
relation_type: 'child', | ||
relation_id: '1a05ec87-3c38-4395-b9f3-aa15becedc31', | ||
}, | ||
{ | ||
org_id: '792a4eee-8e18-4750-a56f-91bdec383aa6', | ||
relation_type: 'child', | ||
relation_id: '1d2fb06e-e8f7-40de-8e13-ed3eba1abb3a', | ||
}, | ||
{ | ||
org_id: '1a05ec87-3c38-4395-b9f3-aa15becedc31', | ||
relation_type: 'parent', | ||
relation_id: '792a4eee-8e18-4750-a56f-91bdec383aa6', | ||
}, | ||
{ | ||
org_id: '1d2fb06e-e8f7-40de-8e13-ed3eba1abb3a', | ||
relation_type: 'parent', | ||
relation_id: '792a4eee-8e18-4750-a56f-91bdec383aa6', | ||
}, | ||
]); | ||
}); | ||
}; |
Oops, something went wrong.