-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
264 additions
and
95 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,7 +1,5 @@ | ||
sudo: required | ||
|
||
langauge: python | ||
|
||
services: | ||
- docker | ||
|
||
|
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
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,17 @@ | ||
{ | ||
"lastRun": "1533377102405-add-images.js", | ||
"migrations": [ | ||
{ | ||
"title": "1533377087768-add-users.js", | ||
"timestamp": 1533418332304 | ||
}, | ||
{ | ||
"title": "1533377095426-add-sequences.js", | ||
"timestamp": 1533418332325 | ||
}, | ||
{ | ||
"title": "1533377102405-add-images.js", | ||
"timestamp": 1533418332609 | ||
} | ||
] | ||
} |
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,22 @@ | ||
'use strict' | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const upSQL = fs.readFileSync(path.join(__dirname, '..', 'sql', '1533377102405-add-images-up.sql')).toString(); | ||
const downSQL = fs.readFileSync(path.join(__dirname, '..', 'sql', '1533377102405-add-images-down.sql')).toString(); | ||
|
||
const dbLoc = require('../../config')[process.env.ENVIRONMENT || 'develop'].db; | ||
const Database = require('../'); | ||
Database.connect(dbLoc); | ||
|
||
module.exports.up = function (next) { | ||
Database.executeSpatial(upSQL) | ||
.then(() => next()) | ||
.catch(error => { console.error(error); next(); }) | ||
} | ||
|
||
module.exports.down = function (next) { | ||
Database.executeSpatial(downSQL) | ||
.then(() => next()) | ||
.catch(error => { console.error(error); next(); }); | ||
} |
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,26 @@ | ||
'use strict'; | ||
|
||
const users = require('../../testData/seeds').users; | ||
const uuidv4 = require('uuid/v4'); | ||
const dbLoc = require('../../config')[process.env.ENVIRONMENT || 'develop'].db; | ||
const Database = require('../'); | ||
|
||
Database.connect(dbLoc); | ||
|
||
let seeds = [ | ||
{ | ||
users: () => { | ||
const values = users.map(user => `('${uuidv4()}', '${user.name}')`).join(','); | ||
const sql = `INSERT INTO Users VALUES ${values};`; | ||
return Database.execute(sql) | ||
.catch((err) => { throw err; }); | ||
} | ||
} | ||
]; | ||
|
||
if (process.argv.slice(2).length > 0) { | ||
seeds = seeds.filter(s => process.argv.includes(Object.keys(s)[0])); | ||
} | ||
|
||
seeds.forEach(s => Object.values(s)[0]()); | ||
|
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 @@ | ||
DROP TABLE IF EXISTS Users; |
2 changes: 1 addition & 1 deletion
2
migrations/1533377087768-add-users-up.sql → db/sql/1533377087768-add-users-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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CREATE TABLE Users ( | ||
CREATE TABLE IF NOT EXISTS Users( | ||
id UUID PRIMARY KEY, | ||
name TEXT NOT NULL | ||
); |
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 @@ | ||
DROP TABLE IF EXISTS Sequences; |
2 changes: 1 addition & 1 deletion
2
...ations/1533377087768-add-sequences-up.sql → db/sql/1533377095426-add-sequences-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
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 @@ | ||
DROP TABLE IF EXISTS Images; |
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
Binary file not shown.
Empty file.
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,22 +1,22 @@ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
const migrate = require('migrate'); | ||
Promise = require('bluebird'); | ||
|
||
const expect = require('chai').expect; | ||
const migrate = Promise.promisifyAll(require('migrate')); | ||
const path = require('path'); | ||
const migrationsPath = path.join(process.cwd(), 'migrations'); | ||
const migrationsPath = path.join(__dirname, '..', 'db', 'migrations'); | ||
const migrationStore = path.join(migrationsPath, '.migrate'); | ||
const migrationOpts = { migrationsDirectory: migrationsPath, stateStore: migrationStore }; | ||
const migrationOpts = { migrationsDirectory: migrationsPath, stateStore: migrationStore }; | ||
|
||
describe('migrations', () => { | ||
it('migrates db up and back down', () => { | ||
migrate.load(migrationOpts, (err, set) => { | ||
if (err) throw err | ||
console.log(set); | ||
set.up((err, res) => { | ||
if (err) throw err; | ||
set.down((err, res) => { if (err) throw err; }) | ||
}); | ||
}); | ||
migrate.loadAsync(migrationOpts) | ||
.then((set) => { | ||
set = Promise.promisifyAll(set); | ||
set.upAsync().then(() => set.downAsync()) | ||
}) | ||
.catch((err) => console.error(err)); | ||
}); | ||
}); | ||
}); | ||
|
Oops, something went wrong.