-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for environments with dotenv
- Loading branch information
1 parent
cf93f5e
commit 08af26c
Showing
13 changed files
with
144 additions
and
4 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 |
---|---|---|
|
@@ -2,3 +2,5 @@ support | |
test | ||
examples | ||
*.sock | ||
.db | ||
.migrate |
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
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 @@ | ||
DB=contributors |
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 @@ | ||
DB=foo |
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,11 @@ | ||
# Environment Example | ||
|
||
``` | ||
$ migrate up --env | ||
$ migrate down --env | ||
$ cat .db # should see table of `contributors` | ||
$ migrate up --env .foo | ||
$ migrate down --env .foo | ||
$ cat .db # should see table of `foo` | ||
``` |
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,44 @@ | ||
'use strict' | ||
var fs = require('fs') | ||
|
||
module.exports = { | ||
loaded: false, | ||
tables: {}, | ||
table: function (name) { | ||
this.tables[name] = [] | ||
this.save() | ||
}, | ||
removeTable: function (name) { | ||
delete this.tables[name] | ||
this.save() | ||
}, | ||
insert: function (table, value) { | ||
this.tables[table].push(value) | ||
this.save() | ||
}, | ||
remove: function (table, value) { | ||
this.tables[table].splice(this.tables[table].indexOf(value), 1) | ||
this.save() | ||
}, | ||
save: function () { | ||
fs.writeFileSync('.db', JSON.stringify(this)) | ||
}, | ||
load: function () { | ||
if (this.loaded) return this | ||
var json | ||
try { | ||
json = JSON.parse(fs.readFileSync('.db', 'utf8')) | ||
} catch (e) { | ||
// ignore | ||
return this | ||
} | ||
this.loaded = true | ||
this.tables = json.tables | ||
return this | ||
}, | ||
toJSON: function () { | ||
return { | ||
tables: this.tables | ||
} | ||
} | ||
} |
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 @@ | ||
DB=pets |
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