mirror of
https://github.com/symfony/recipes.git
synced 2026-09-11 23:26:27 +03:00
feat: switch to Postgres
This commit is contained in:
committed by
Fabien Potencier
parent
ade1a9c1cb
commit
6a91adfe62
@@ -9,29 +9,32 @@
|
||||
"env": {
|
||||
"#1": "Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url",
|
||||
"#2": "For an SQLite database, use: \"sqlite:///%kernel.project_dir%/var/data.db\"",
|
||||
"#3": "For a PostgreSQL database, use: \"postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8\"",
|
||||
"#4": "For the Docker integration, use: \"mysql://symfony:ChangeMe@db:3306/app?serverVersion=mariadb-10.5.6\"",
|
||||
"#3": "For a MySQL database, use: \"mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7\"",
|
||||
"#5": "IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml",
|
||||
"DATABASE_URL": "mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
|
||||
"DATABASE_URL": "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
|
||||
},
|
||||
"dockerfile": ["RUN docker-php-ext-install pdo_mysql"],
|
||||
"dockerfile": [
|
||||
"RUN apk add --no-cache --virtual .pgsql-deps postgresql-dev; \\",
|
||||
"\tdocker-php-ext-install -j$(nproc) pdo_pgsql; \\",
|
||||
"\tapk add --no-cache --virtual .pgsql-rundeps so:libpq.so.5; \\",
|
||||
"\tapk del .pgsql-deps"
|
||||
],
|
||||
"docker-compose": {
|
||||
"services": [
|
||||
"db:",
|
||||
" image: mariadb:${MARIADB_VERSION:-10.5.6}",
|
||||
" image: postgres:${POSTGRES_VERSION:-13}-alpine",
|
||||
" environment:",
|
||||
" MYSQL_DATABASE: ${MYSQL_DATABASE:-app}",
|
||||
" POSTGRES_DB: ${POSTGRES_DB:-app}",
|
||||
" # You should definitely change the password in production",
|
||||
" MYSQL_PASSWORD: ${MYSQL_PASSWORD:-ChangeMe}",
|
||||
" MYSQL_RANDOM_ROOT_PASSWORD: \"true\"",
|
||||
" MYSQL_USER: ${MYSQL_USER:-symfony}",
|
||||
" POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-ChangeMe}",
|
||||
" POSTGRES_USER: ${POSTGRES_USER:-symfony}",
|
||||
" volumes:",
|
||||
" - db-data:/var/lib/mysql:rw",
|
||||
" - db-data:/var/lib/postgresql/data:rw",
|
||||
" # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!",
|
||||
" # - ./docker/db/data:/var/lib/mysql:rw",
|
||||
" # - ./docker/db/data:/var/lib/postgresql/data:rw",
|
||||
" # To expose the port on the host",
|
||||
" # ports:",
|
||||
" # - \"3306\""
|
||||
" # - \"5432\""
|
||||
],
|
||||
"volumes": ["db-data:"]
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ doctrine:
|
||||
|
||||
# IMPORTANT: You MUST configure your server version,
|
||||
# either here or in the DATABASE_URL env var (see .env file)
|
||||
#server_version: '5.7'
|
||||
#server_version: '13'
|
||||
orm:
|
||||
auto_generate_proxy_classes: true
|
||||
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
|
||||
|
||||
Reference in New Issue
Block a user