Change default behavior of ENABLE DB MIGRATION (#9077)

See:
https://github.com/twentyhq/twenty/issues/9031#issuecomment-2542015975

I think it would be easier if the default behavior for the container was
to run the migration, and setting the environment variable would be used
to disable it (e.g. on the worker).

Long-term goal is for the default setup to work out of the box with ~2
env variables only (database url, redis url)

I don't think there's a big risk if people forget to turn it off on the
worker?
This commit is contained in:
Félix Malfait
2024-12-16 17:31:45 +01:00
committed by GitHub
parent 449be46936
commit c90d2fd5cc
8 changed files with 17 additions and 26 deletions

View File

@ -2,20 +2,14 @@ TAG=latest
#PGUSER_SUPERUSER=postgres #PGUSER_SUPERUSER=postgres
#PGPASSWORD_SUPERUSER=replace_me_with_a_strong_password #PGPASSWORD_SUPERUSER=replace_me_with_a_strong_password
#PG_DATABASE_HOST=db
PG_DATABASE_HOST=db:5432 #REDIS_URL=redis://redis:6379
REDIS_URL=redis://redis:6379
SERVER_URL=http://localhost:3000 SERVER_URL=http://localhost:3000
FRONT_DOMAIN=localhost
FRONT_PORT=3000
FRONT_PROTOCOL=http
# Use openssl rand -base64 32 for each secret # Use openssl rand -base64 32 for each secret
# APP_SECRET=replace_me_with_a_random_string # APP_SECRET=replace_me_with_a_random_string
SIGN_IN_PREFILLED=true
STORAGE_TYPE=local STORAGE_TYPE=local
# STORAGE_S3_REGION=eu-west3 # STORAGE_S3_REGION=eu-west3

View File

@ -26,8 +26,6 @@ services:
SERVER_URL: ${SERVER_URL} SERVER_URL: ${SERVER_URL}
REDIS_URL: ${REDIS_URL:-redis://redis:6379} REDIS_URL: ${REDIS_URL:-redis://redis:6379}
ENABLE_DB_MIGRATIONS: "true"
SIGN_IN_PREFILLED: ${SIGN_IN_PREFILLED} SIGN_IN_PREFILLED: ${SIGN_IN_PREFILLED}
STORAGE_TYPE: ${STORAGE_TYPE} STORAGE_TYPE: ${STORAGE_TYPE}
STORAGE_S3_REGION: ${STORAGE_S3_REGION} STORAGE_S3_REGION: ${STORAGE_S3_REGION}
@ -54,7 +52,7 @@ services:
PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${PG_DATABASE_HOST:-db:5432}/default PG_DATABASE_URL: postgres://${PGUSER_SUPERUSER:-postgres}:${PGPASSWORD_SUPERUSER:-postgres}@${PG_DATABASE_HOST:-db:5432}/default
SERVER_URL: ${SERVER_URL} SERVER_URL: ${SERVER_URL}
REDIS_URL: ${REDIS_URL:-redis://redis:6379} REDIS_URL: ${REDIS_URL:-redis://redis:6379}
ENABLE_DB_MIGRATIONS: "false" # it already runs on the server DISABLE_DB_MIGRATIONS: "true" # it already runs on the server
STORAGE_TYPE: ${STORAGE_TYPE} STORAGE_TYPE: ${STORAGE_TYPE}
STORAGE_S3_REGION: ${STORAGE_S3_REGION} STORAGE_S3_REGION: ${STORAGE_S3_REGION}

View File

@ -41,10 +41,8 @@ spec:
value: "postgres://postgres:postgres@twentycrm-db.twentycrm.svc.cluster.local/default" value: "postgres://postgres:postgres@twentycrm-db.twentycrm.svc.cluster.local/default"
- name: "REDIS_URL" - name: "REDIS_URL"
value: "redis://twentycrm-redis.twentycrm.svc.cluster.local:6379" value: "redis://twentycrm-redis.twentycrm.svc.cluster.local:6379"
- name: ENABLE_DB_MIGRATIONS
value: "true"
- name: SIGN_IN_PREFILLED - name: SIGN_IN_PREFILLED
value: "true" value: "false"
- name: STORAGE_TYPE - name: STORAGE_TYPE
value: "local" value: "local"
- name: "MESSAGE_QUEUE_TYPE" - name: "MESSAGE_QUEUE_TYPE"

View File

@ -30,7 +30,7 @@ spec:
value: "https://crm.example.com:443" value: "https://crm.example.com:443"
- name: PG_DATABASE_URL - name: PG_DATABASE_URL
value: "postgres://postgres:postgres@twentycrm-db.twentycrm.svc.cluster.local/default" value: "postgres://postgres:postgres@twentycrm-db.twentycrm.svc.cluster.local/default"
- name: ENABLE_DB_MIGRATIONS - name: DISABLE_DB_MIGRATIONS
value: "false" # it already runs on the server value: "false" # it already runs on the server
- name: STORAGE_TYPE - name: STORAGE_TYPE
value: "local" value: "local"

View File

@ -60,13 +60,8 @@ resource "kubernetes_deployment" "twentycrm_server" {
value = "redis://${kubernetes_service.twentycrm_redis.metadata.0.name}.${kubernetes_namespace.twentycrm.metadata.0.name}.svc.cluster.local:6379" value = "redis://${kubernetes_service.twentycrm_redis.metadata.0.name}.${kubernetes_namespace.twentycrm.metadata.0.name}.svc.cluster.local:6379"
} }
env { env {
name = "ENABLE_DB_MIGRATIONS" name = "DISABLE_DB_MIGRATIONS"
value = "true" value = "false"
}
env {
name = "SIGN_IN_PREFILLED"
value = "true"
} }
env { env {

View File

@ -59,8 +59,8 @@ resource "kubernetes_deployment" "twentycrm_worker" {
} }
env { env {
name = "ENABLE_DB_MIGRATIONS" name = "DISABLE_DB_MIGRATIONS"
value = "false" #it already runs on the server value = "true" #it already runs on the server
} }
env { env {

View File

@ -2,7 +2,7 @@
set -e set -e
# Check if the initialization has already been done and that we enabled automatic migration # Check if the initialization has already been done and that we enabled automatic migration
if [ "${ENABLE_DB_MIGRATIONS}" = "true" ] && [ ! -f /app/docker-data/db_status ]; then if [ "${DISABLE_DB_MIGRATIONS}" != "true" ] && [ ! -f /app/docker-data/db_status ]; then
echo "Running database setup and migrations..." echo "Running database setup and migrations..."
# Creating the database if it doesn't exist # Creating the database if it doesn't exist

View File

@ -20,6 +20,12 @@ If you used Docker Compose, follow these steps:
## Version-specific upgrade steps ## Version-specific upgrade steps
### v0.34.0 to v0.40.0
- We replaced `ENABLE_DB_MIGRATIONS` with `DISABLE_DB_MIGRATIONS` (default value is now `false`, you probably don't have to set anything)
### v0.33.0 to v0.34.0 ### v0.33.0 to v0.34.0
Upgrade your Twenty instance to use v0.34.0 image Upgrade your Twenty instance to use v0.34.0 image
@ -172,4 +178,4 @@ The `yarn command:prod upgrade-0.22` command will apply specific data transforma
<ArticleEditContent></ArticleEditContent> <ArticleEditContent></ArticleEditContent>