Rebuild: fresh AdonisJS 7 API app on Postgres
The rebuild branch starts over (REBUILD.md): the API starter kit, with Postgres instead of SQLite (its own database, DB_SEARCH_PATH for a shared one in development) and the #lib alias. Phase 1's code is imported from the current app module by module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
699395c51f
commit
96f0ade10e
264 files changed
+777
-24132
No files matched your search
+14
-115
@@ -1,137 +1,36 @@
|
||||
import env from '#start/env'
|
||||
import app from '@adonisjs/core/services/app'
|
||||
import { defineConfig } from '@adonisjs/lucid'
|
||||
import env from '#start/env'
|
||||
|
||||
/**
|
||||
* The rebuild's own database (REBUILD.md, decision b), on the same server
|
||||
* as the current indexer's.
|
||||
*/
|
||||
const dbConfig = defineConfig({
|
||||
/**
|
||||
* Default connection used for all queries.
|
||||
*/
|
||||
connection: env.get('DB_CONNECTION', 'sqlite'),
|
||||
|
||||
connection: 'pg',
|
||||
connections: {
|
||||
/**
|
||||
* SQLite connection (default).
|
||||
*/
|
||||
sqlite: {
|
||||
client: 'better-sqlite3',
|
||||
|
||||
connection: {
|
||||
filename: app.tmpPath('db.sqlite3'),
|
||||
},
|
||||
|
||||
/**
|
||||
* Required by Knex for SQLite defaults.
|
||||
*/
|
||||
useNullAsDefault: true,
|
||||
|
||||
migrations: {
|
||||
/**
|
||||
* Sort migration files naturally by filename.
|
||||
*/
|
||||
naturalSort: true,
|
||||
|
||||
/**
|
||||
* Paths containing migration files.
|
||||
*/
|
||||
paths: ['database/migrations'],
|
||||
},
|
||||
|
||||
schemaGeneration: {
|
||||
/**
|
||||
* Enable schema generation from Lucid models.
|
||||
*/
|
||||
enabled: true,
|
||||
|
||||
/**
|
||||
* Custom schema rules file paths.
|
||||
*/
|
||||
rulesPaths: ['./database/schema_rules.js'],
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* PostgreSQL connection.
|
||||
* Install package to switch: npm install pg
|
||||
*/
|
||||
pg: {
|
||||
client: 'pg',
|
||||
connection: {
|
||||
host: env.get('DB_HOST'),
|
||||
port: env.get('DB_PORT'),
|
||||
user: env.get('DB_USER'),
|
||||
password: env.get('DB_PASSWORD')?.release(),
|
||||
password: env.get('DB_PASSWORD'),
|
||||
database: env.get('DB_DATABASE'),
|
||||
// For idempotent bulk writers (worker:fetch): don't wait for the WAL
|
||||
// flush on every statement. A crash loses the last moments of writes,
|
||||
// which the retried job writes again.
|
||||
...(env.get('DB_SYNCHRONOUS_COMMIT') === 'off' ? { options: '-c synchronous_commit=off' } : {}),
|
||||
},
|
||||
// One connection per concurrent job; knex defaults to 10.
|
||||
// Local development may share a database, in its own schema (DB_SEARCH_PATH=rebuild).
|
||||
...(env.get('DB_SEARCH_PATH') ? { searchPath: env.get('DB_SEARCH_PATH')!.split(',') } : {}),
|
||||
pool: { min: 0, max: env.get('DB_POOL_MAX', 10) },
|
||||
migrations: {
|
||||
naturalSort: true,
|
||||
paths: ['database/migrations'],
|
||||
},
|
||||
debug: app.inDev,
|
||||
schemaGeneration: {
|
||||
enabled: true,
|
||||
rulesPaths: ['./database/schema_rules.js'],
|
||||
},
|
||||
debug: app.inDev && env.get('DB_DEBUG', false),
|
||||
},
|
||||
|
||||
/**
|
||||
* MySQL / MariaDB connection.
|
||||
* Install package to switch: npm install mysql2
|
||||
*/
|
||||
// mysql: {
|
||||
// client: 'mysql2',
|
||||
// connection: {
|
||||
// host: env.get('DB_HOST'),
|
||||
// port: env.get('DB_PORT'),
|
||||
// user: env.get('DB_USER'),
|
||||
// password: env.get('DB_PASSWORD'),
|
||||
// database: env.get('DB_DATABASE'),
|
||||
// },
|
||||
// migrations: {
|
||||
// naturalSort: true,
|
||||
// paths: ['database/migrations'],
|
||||
// },
|
||||
// debug: app.inDev,
|
||||
// },
|
||||
|
||||
/**
|
||||
* Microsoft SQL Server connection.
|
||||
* Install package to switch: npm install tedious
|
||||
*/
|
||||
// mssql: {
|
||||
// client: 'mssql',
|
||||
// connection: {
|
||||
// server: env.get('DB_HOST'),
|
||||
// port: env.get('DB_PORT'),
|
||||
// user: env.get('DB_USER'),
|
||||
// password: env.get('DB_PASSWORD'),
|
||||
// database: env.get('DB_DATABASE'),
|
||||
// },
|
||||
// migrations: {
|
||||
// naturalSort: true,
|
||||
// paths: ['database/migrations'],
|
||||
// },
|
||||
// debug: app.inDev,
|
||||
// },
|
||||
|
||||
/**
|
||||
* libSQL (Turso) connection.
|
||||
* Install package to switch: npm install @libsql/client
|
||||
*/
|
||||
// libsql: {
|
||||
// client: 'libsql',
|
||||
// connection: {
|
||||
// url: env.get('LIBSQL_URL'),
|
||||
// authToken: env.get('LIBSQL_AUTH_TOKEN'),
|
||||
// },
|
||||
// useNullAsDefault: true,
|
||||
// migrations: {
|
||||
// naturalSort: true,
|
||||
// paths: ['database/migrations'],
|
||||
// },
|
||||
// debug: app.inDev,
|
||||
// },
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user