feat(db): add migration for volume column type change
- Create migration 0002_alter_volume_type.sql to change volume from TEXT to INTEGER - Update docker-compose to run all migrations automatically using env variables - Enables proper numeric sorting of volumes (1, 2, 3 instead of 01, 02, 03)
This commit is contained in:
@@ -34,13 +34,15 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
env_file:
|
||||||
|
- ../.env
|
||||||
volumes:
|
volumes:
|
||||||
- ./migrations:/migrations:ro
|
- ./migrations:/migrations:ro
|
||||||
command:
|
command:
|
||||||
[
|
[
|
||||||
"sh",
|
"sh",
|
||||||
"-c",
|
"-c",
|
||||||
"PGPASSWORD=stripstream psql -h postgres -U stripstream -d stripstream -f /migrations/0001_init.sql",
|
"for f in /migrations/*.sql; do echo \"Applying migration: $f\"; psql -h postgres -U \"$${POSTGRES_USER:-stripstream}\" -d \"$${POSTGRES_DB:-stripstream}\" -f \"$f\" || exit 1; done",
|
||||||
]
|
]
|
||||||
|
|
||||||
api:
|
api:
|
||||||
|
|||||||
4
infra/migrations/0002_alter_volume_type.sql
Normal file
4
infra/migrations/0002_alter_volume_type.sql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
-- Migration: Change volume column type from TEXT to INTEGER
|
||||||
|
-- This allows proper numeric sorting and removes leading zeros
|
||||||
|
|
||||||
|
ALTER TABLE books ALTER COLUMN volume TYPE INTEGER USING volume::integer;
|
||||||
Reference in New Issue
Block a user