update db template

This commit is contained in:
Dieter Stinglhamber 2022-08-31 14:20:27 +02:00
parent db25b274e0
commit 5b5fe16dd7
2 changed files with 24 additions and 14 deletions

View File

@ -5,7 +5,7 @@ module.exports = ({ env }) => {
const connections = {
mysql: {
connection: {
connection: env('DATABASE_URL') || {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),
database: env('DATABASE_NAME', 'strapi'),
@ -22,7 +22,7 @@ module.exports = ({ env }) => {
},
},
postgres: {
connection: {
connection: env('DATABASE_URL') || {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 5431),
database: env('DATABASE_NAME', 'strapi'),
@ -40,18 +40,16 @@ module.exports = ({ env }) => {
},
sqlite: {
connection: {
filename: path.join(__dirname, '..', env('DATABASE_FILENAME', 'data.db')),
filename: env('DATABASE_URL') || path.join(__dirname, '..', env('DATABASE_FILENAME', 'data.db')),
},
useNullAsDefault: true,
}
}
const connection = env('DATABASE_URL') ? { connection: env('DATABASE_URL') } : connections[client]
return {
connection: {
client,
...connection,
...connections[client],
},
};
}

View File

@ -5,39 +5,51 @@ export default ({ env }) => {
const connections = {
mysql: {
connection: {
connection: env('DATABASE_URL') || {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool('DATABASE_SSL_REJECT_UNAUTHORIZED', true),
},
},
},
postgres: {
connection: {
connection: env('DATABASE_URL') || {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 5431),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool('DATABASE_SSL_REJECT_UNAUTHORIZED', true),
},
},
},
sqlite: {
connection: {
filename: path.join(__dirname, '..', '..', env('DATABASE_FILENAME', 'data.db')),
filename: env('DATABASE_URL') || path.join(__dirname, '..', env('DATABASE_FILENAME', 'data.db')),
},
useNullAsDefault: true,
}
}
const connection = env('DATABASE_URL') ? { connection: env('DATABASE_URL') } : connections[client]
return {
connection: {
client,
...connection,
...connections[client],
},
};
}