This commit is contained in:
Tutur33
2023-11-24 22:35:41 +01:00
parent 3c0b507a93
commit 7644b2a0f7
45165 changed files with 4803356 additions and 3 deletions
+177
View File
@@ -0,0 +1,177 @@
/**
* Config source: https://git.io/JesV9
*
* Feel free to let us know via PR, if you find something broken in this config
* file.
*/
import Env from '@ioc:Adonis/Core/Env'
{{#sqlite}}
import Application from '@ioc:Adonis/Core/Application'
{{/sqlite}}
import type { DatabaseConfig } from '@ioc:Adonis/Lucid/Database'
const databaseConfig: DatabaseConfig = {
/*
|--------------------------------------------------------------------------
| 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'),
connections: {
{{#sqlite}}
/*
|--------------------------------------------------------------------------
| 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'),
},
pool: {
afterCreate: (conn, cb) => {
conn.run('PRAGMA foreign_keys=true', cb)
}
},
migrations: {
naturalSort: true,
},
useNullAsDefault: true,
healthCheck: false,
debug: false,
},
{{/sqlite}}
{{#mysql}}
/*
|--------------------------------------------------------------------------
| MySQL config
|--------------------------------------------------------------------------
|
| Configuration for MySQL database. Make sure to install the driver
| from npm when using this connection
|
| npm i mysql2
|
*/
mysql: {
client: 'mysql2',
connection: {
host: Env.get('MYSQL_HOST'),
port: Env.get('MYSQL_PORT'),
user: Env.get('MYSQL_USER'),
password: Env.get('MYSQL_PASSWORD', ''),
database: Env.get('MYSQL_DB_NAME'),
},
migrations: {
naturalSort: true,
},
healthCheck: false,
debug: false,
},
{{/mysql}}
{{#psql}}
/*
|--------------------------------------------------------------------------
| PostgreSQL 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('PG_HOST'),
port: Env.get('PG_PORT'),
user: Env.get('PG_USER'),
password: Env.get('PG_PASSWORD', ''),
database: Env.get('PG_DB_NAME'),
},
migrations: {
naturalSort: true,
},
healthCheck: false,
debug: false,
},
{{/psql}}
{{#oracle}}
/*
|--------------------------------------------------------------------------
| OracleDB config
|--------------------------------------------------------------------------
|
| Configuration for Oracle database. Make sure to install the driver
| from npm when using this connection
|
| npm i oracledb
|
*/
oracle: {
client: 'oracledb',
connection: {
host: Env.get('ORACLE_HOST'),
port: Env.get('ORACLE_PORT'),
user: Env.get('ORACLE_USER'),
password: Env.get('ORACLE_PASSWORD', ''),
database: Env.get('ORACLE_DB_NAME'),
},
migrations: {
naturalSort: true,
},
healthCheck: false,
debug: false,
},
{{/oracle}}
{{#mssql}}
/*
|--------------------------------------------------------------------------
| MSSQL config
|--------------------------------------------------------------------------
|
| Configuration for MSSQL database. Make sure to install the driver
| from npm when using this connection
|
| npm i tedious
|
*/
mssql: {
client: 'mssql',
connection: {
user: Env.get('MSSQL_USER'),
port: Env.get('MSSQL_PORT'),
server: Env.get('MSSQL_SERVER'),
password: Env.get('MSSQL_PASSWORD', ''),
database: Env.get('MSSQL_DB_NAME'),
},
migrations: {
naturalSort: true,
},
healthCheck: false,
debug: false,
}
{{/mssql}}
}
}
export default databaseConfig
+1
View File
@@ -0,0 +1 @@
// import Factory from '@ioc:Adonis/Lucid/Factory'
+8
View File
@@ -0,0 +1,8 @@
import {{#toModelName}}{{{ model }}}{{/toModelName}} from '{{{ modelImportPath }}}'
import Factory from '@ioc:Adonis/Lucid/Factory'
export default Factory.define({{#toModelName}}{{{ model }}}{{/toModelName}}, ({ faker }) => {
return {
//
}
}).build()
+15
View File
@@ -0,0 +1,15 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
export default class extends BaseSchema {
protected tableName = '{{#toTableName}}{{ filename }}{{/toTableName}}'
public async up () {
this.schema.alterTable(this.tableName, (table) => {
})
}
public async down () {
this.schema.alterTable(this.tableName, (table) => {
})
}
}
+21
View File
@@ -0,0 +1,21 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
export default class extends BaseSchema {
protected tableName = '{{#toTableName}}{{ filename }}{{/toTableName}}'
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
/**
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
*/
table.timestamp('created_at', { useTz: true })
table.timestamp('updated_at', { useTz: true })
})
}
public async down () {
this.schema.dropTable(this.tableName)
}
}
+13
View File
@@ -0,0 +1,13 @@
import { DateTime } from 'luxon'
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
export default class {{ filename }} extends BaseModel {
@column({ isPrimary: true })
public id: number
@column.dateTime({ autoCreate: true })
public createdAt: DateTime
@column.dateTime({ autoCreate: true, autoUpdate: true })
public updatedAt: DateTime
}
+7
View File
@@ -0,0 +1,7 @@
import BaseSeeder from '@ioc:Adonis/Lucid/Seeder'
export default class extends BaseSeeder {
public async run () {
// Write your database queries inside the run method
}
}