-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
466 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Contributing | ||
|
||
In favor of active development we accept contributions from everyone. You can contribute by submitting a bug, creating pull requests or even by improving documentation. | ||
|
||
Below is the guide to be followed strictly before submitting your pull requests. | ||
http://adonisjs.com/docs/2.0/contributing |
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,20 @@ | ||
'use strict' | ||
|
||
/** | ||
* adonis-lucid | ||
* Copyright(c) 2015-2015 Harminder Virk | ||
* MIT Licensed | ||
*/ | ||
|
||
const fs = require('co-fs-extra') | ||
const path = require('path') | ||
|
||
module.exports = { | ||
cleanStorage: function * () { | ||
return yield fs.emptyDir(path.join(__dirname,'../storage')) | ||
}, | ||
createDir: function * () { | ||
return yield fs.ensureDir(path.join(__dirname,'../storage')) | ||
} | ||
} | ||
|
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,85 @@ | ||
'use strict' | ||
|
||
const bluebird = require('bluebird') | ||
|
||
module.exports = { | ||
up: function (knex) { | ||
const tables = [ | ||
knex.schema.createTable('users', function (table) { | ||
table.increments() | ||
table.string('username') | ||
table.string('firstname') | ||
table.string('lastname') | ||
table.string('status') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}), | ||
knex.schema.createTable('accounts', function (table) { | ||
table.increments() | ||
table.string('account_name') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}), | ||
knex.schema.createTable('profiles', function (table) { | ||
table.increments() | ||
table.integer('user_id') | ||
table.string('display_name') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}), | ||
knex.schema.createTable('cars', function (table) { | ||
table.increments() | ||
table.integer('user_id') | ||
table.string('car_name') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}), | ||
knex.schema.createTable('keys', function (table) { | ||
table.increments() | ||
table.integer('car_id') | ||
table.string('key_number') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}) | ||
] | ||
return bluebird.all(tables) | ||
}, | ||
|
||
down: function (knex) { | ||
const dropTables = [ | ||
knex.schema.dropTable('users'), | ||
knex.schema.dropTable('accounts'), | ||
knex.schema.dropTable('profiles'), | ||
knex.schema.dropTable('cars'), | ||
knex.schema.dropTable('keys') | ||
] | ||
return bluebird.all(dropTables) | ||
}, | ||
|
||
setupAccount: function (knex) { | ||
return knex.table('accounts').insert({account_name: 'sales', created_at: new Date(), updated_at: new Date()}) | ||
}, | ||
|
||
setupProfile: function (knex) { | ||
return knex.table('profiles').insert({user_id: 1, display_name: 'virk', created_at: new Date(), updated_at: new Date()}) | ||
}, | ||
|
||
setupCar: function (knex) { | ||
return knex.table('cars').insert({user_id: 1, car_name: 'audi a6', created_at: new Date(), updated_at: new Date()}) | ||
}, | ||
|
||
setupCarKey: function (knex) { | ||
return knex.table('keys').insert({car_id: 1, key_number: '98010291222', created_at: new Date(), updated_at: new Date()}) | ||
}, | ||
|
||
setupUser: function (knex) { | ||
return knex.table('users').insert({ | ||
firstname: 'aman', | ||
lastname: 'virk', | ||
username: 'avirk', | ||
created_at: new Date(), | ||
updated_at: new Date() | ||
}) | ||
} | ||
|
||
} |
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,77 @@ | ||
'use strict' | ||
|
||
/** | ||
* adonis-lucid | ||
* Copyright(c) 2016-2016 Harminder Virk | ||
* MIT Licensed | ||
*/ | ||
|
||
const path = require('path') | ||
const bluebird = require('bluebird') | ||
const files = require('./files') | ||
|
||
module.exports = { | ||
setupTables: function (knex) { | ||
const tables = [ | ||
knex.schema.createTable('suppliers', function (table) { | ||
table.increments() | ||
table.string('name') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}), | ||
knex.schema.createTable('accounts', function (table) { | ||
table.increments() | ||
table.integer('supplier_id') | ||
table.string('name') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}), | ||
knex.schema.createTable('all_suppliers', function (table) { | ||
table.increments() | ||
table.string('regid').unique() | ||
table.string('name') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}), | ||
knex.schema.createTable('all_accounts', function (table) { | ||
table.increments() | ||
table.string('supplier_regid') | ||
table.string('name') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}), | ||
knex.schema.createTable('users', function (table) { | ||
table.increments() | ||
table.string('username') | ||
table.integer('manager_id') | ||
table.string('type') | ||
table.timestamps() | ||
table.timestamp('deleted_at').nullable() | ||
}) | ||
] | ||
return bluebird.all(tables) | ||
}, | ||
dropTables: function (knex) { | ||
const tables = [ | ||
knex.schema.dropTable('accounts'), | ||
knex.schema.dropTable('suppliers'), | ||
knex.schema.dropTable('all_accounts'), | ||
knex.schema.dropTable('all_suppliers'), | ||
knex.schema.dropTable('users') | ||
] | ||
return bluebird.all(tables) | ||
}, | ||
createRecords: function * (knex, table, values) { | ||
return yield knex.table(table).insert(values) | ||
}, | ||
truncate: function * (knex, table) { | ||
yield knex.table(table).truncate() | ||
}, | ||
up: function * (knex) { | ||
yield files.createDir() | ||
yield this.setupTables(knex) | ||
}, | ||
down: function * (knex) { | ||
yield this.dropTables(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,34 @@ | ||
'use strict' | ||
|
||
/** | ||
* adonis-lucid | ||
* Copyright(c) 2016-2016 Harminder Virk | ||
* MIT Licensed | ||
*/ | ||
const path = require('path') | ||
const mysqlConnections = require('./mysqlConnections') | ||
const sqliteConnections = require('./sqliteConnections') | ||
|
||
module.exports = { | ||
get: function (key) { | ||
if (key === 'database.connection') { | ||
return process.env.DB | ||
} | ||
|
||
if (key === 'database.sqlite3') { | ||
return sqliteConnections.default | ||
} | ||
|
||
if (key === 'database.mysql') { | ||
return mysqlConnections.default | ||
} | ||
|
||
if (key === 'database.alternateConnection' && process.env.DB === 'sqlite3') { | ||
return sqliteConnections.alternateConnection | ||
} | ||
|
||
if (key === 'database.alternateConnection' && process.env.DB === 'mysql') { | ||
return mysqlConnections.alternateConnection | ||
} | ||
} | ||
} |
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,27 @@ | ||
'use strict' | ||
|
||
/** | ||
* adonis-lucid | ||
* Copyright(c) 2016-2016 Harminder Virk | ||
* MIT Licensed | ||
*/ | ||
|
||
module.exports = { | ||
default : { | ||
client: 'mysql', | ||
connection: { | ||
user : 'root', | ||
password : '', | ||
database : 'default' | ||
} | ||
}, | ||
|
||
alternateConnection: { | ||
client: 'mysql', | ||
connection: { | ||
user : 'root', | ||
password : '', | ||
database : 'alternate' | ||
} | ||
} | ||
} |
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 @@ | ||
'use strict' | ||
|
||
/** | ||
* adonis-lucid | ||
* Copyright(c) 2016-2016 Harminder Virk | ||
* MIT Licensed | ||
*/ | ||
|
||
module.exports = { | ||
formatQuery: function (query) { | ||
if(process.env.DB === 'mysql') { | ||
return query.replace(/"/g, '`') | ||
} | ||
return query | ||
} | ||
} |
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,27 @@ | ||
'use strict' | ||
|
||
/** | ||
* adonis-lucid | ||
* Copyright(c) 2016-2016 Harminder Virk | ||
* MIT Licensed | ||
*/ | ||
const path = require('path') | ||
|
||
module.exports = { | ||
default : { | ||
client: 'sqlite3', | ||
connection: { | ||
filename: path.join(__dirname, '../storage/test.sqlite3') | ||
}, | ||
useNullAsDefault: true, | ||
debug: false | ||
}, | ||
|
||
alternateConnection: { | ||
client: 'sqlite3', | ||
connection: { | ||
filename: path.join(__dirname, '../storage/test2.sqlite3') | ||
}, | ||
useNullAsDefault: true | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.