-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
1 parent
e094a0a
commit 9ed0bcd
Showing
3 changed files
with
149 additions
and
9 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,91 @@ | ||
/** | ||
* Config source: https://git.io/fjS7M | ||
* | ||
* Feel free to let us know via PR, if you find something broken in this config | ||
* file. | ||
*/ | ||
|
||
import Env from '@ioc:Adonis/Core/Env' | ||
import Application from '@ioc:Adonis/Core/Application' | ||
import { DatabaseConfigContract } from '@ioc:Adonis/Lucid/Database' | ||
|
||
const databaseConfig: DatabaseConfigContract = { | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Connection | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The primary connection for making database queries across the application | ||
| You can use any key from the `connections` object defined in this same | ||
| file. | ||
| | ||
*/ | ||
connection: Env.get('DB_CONNECTION', 'sqlite'), | ||
|
||
connections: { | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Sqlite | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Configuration for the Sqlite database. Make sure to install the driver | ||
| from npm when using this connection | ||
| | ||
| npm i sqlite3 | ||
| | ||
*/ | ||
sqlite: { | ||
client: 'sqlite', | ||
connection: { | ||
filename: Application.tmpPath('db.sqlite3'), | ||
}, | ||
useNullAsDefault: true | ||
}, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Mysql config | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Configuration for Mysql database. Make sure to install the driver | ||
| from npm when using this connection | ||
| | ||
| npm i mysql | ||
| | ||
*/ | ||
mysql: { | ||
client: 'mysql', | ||
connection: { | ||
host?: Env.get('DB_HOST', '127.0.0.1'), | ||
port?: Env.get('DB_PORT', 3306) as number, | ||
user?: Env.get('DB_USER', 'lucid'), | ||
password?: Env.get('DB_PASSWORD', 'lucid'), | ||
database?: Env.get('DB_NAME', 'lucid'), | ||
}, | ||
}, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| PostreSQL config | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Configuration for postgreSQL database. Make sure to install the driver | ||
| from npm when using this connection | ||
| | ||
| npm i pg | ||
| | ||
*/ | ||
pg: { | ||
client: 'pg', | ||
connection: { | ||
host?: Env.get('DB_HOST', '127.0.0.1'), | ||
port?: Env.get('DB_PORT', 5432) as number, | ||
user?: Env.get('DB_USER', 'lucid'), | ||
password?: Env.get('DB_PASSWORD', 'lucid'), | ||
database?: Env.get('DB_NAME', 'lucid'), | ||
}, | ||
} | ||
} | ||
} | ||
|
||
export default databaseConfig |
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,39 @@ | ||
/* | ||
* @adonisjs/lucid | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { join } from 'path' | ||
import sinkStatic from '@adonisjs/sink' | ||
import { ApplicationContract } from '@poppinss/application' | ||
|
||
export function instructions ( | ||
projectRoot: string, | ||
application: ApplicationContract, | ||
{ TemplateFile, EnvFile, kleur }: typeof sinkStatic, | ||
) { | ||
const dest = `${application.directoriesMap.get('config')}/database.ts` | ||
const src = join(__dirname, 'config', 'database.txt') | ||
|
||
new TemplateFile(projectRoot, dest, src) | ||
.apply({}) | ||
.commit() | ||
|
||
console.log(` create ${kleur.green(dest)}`) | ||
|
||
const env = new EnvFile('.env') | ||
|
||
env.set('DB_CONNECTION', 'sqlite') | ||
env.set('DB_HOST', '127.0.0.1') | ||
env.set('DB_USER', 'lucid') | ||
env.set('DB_PASSWORD', 'lucid') | ||
env.set('DB_NAME', 'lucid') | ||
|
||
env.commit() | ||
|
||
console.log(` update ${kleur.green('.env')}`) | ||
} |
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