diff --git a/.env.example b/.env.example index 3bf65e15..4ce47ade 100644 --- a/.env.example +++ b/.env.example @@ -21,10 +21,6 @@ DATABASE_LABEL=stage DATABASE_USERNAME=toBeChanged DATABASE_PASSWORD=toBeChanged -# Local DB -# DATABASE_LABEL=local -# USE_LOCAL_DB=true - # AWS S3 connection settings AWS_ACCESS_KEY_ID=toBeChanged AWS_SECRET_ACCESS_KEY=toBeChanged diff --git a/package.json b/package.json index 52e5f69d..0b219dc0 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,10 @@ "test:e2e:dev": "playwright test --ui", "db:generate": "SKIP_ENV_VALIDATION=true drizzle-kit generate:mysql", "db:push": "drizzle-kit push:mysql", - "db-local:studio": "drizzle-kit studio", - "db-local:migrate": "node ./src/server/db/migrate.mjs", - "db-local:run-app": "USE_LOCAL_DB=true next dev", + "db:studio": "drizzle-kit studio", + "db-local:studio": "USE_LOCAL_DB=true drizzle-kit studio", + "db-local:migrate": "USE_LOCAL_DB=true node ./src/server/db/migrate.mjs", + "db-local:run-app": "USE_LOCAL_DB=true DATABASE_LABEL=local next dev", "db-local:run-db": "docker run --name descobreix-begur-app-database -e MYSQL_ROOT_PASSWORD=unsafePaswordOnlyForLocalhost -e MYSQL_DATABASE=descobreix-begur-app -p 3306:3306 mysql" }, "dependencies": { diff --git a/src/server/db/migrate.mjs b/src/server/db/migrate.mjs index ece9f906..abf36e0d 100644 --- a/src/server/db/migrate.mjs +++ b/src/server/db/migrate.mjs @@ -3,9 +3,8 @@ import { migrate } from 'drizzle-orm/mysql2/migrator' import { drizzle as drizzleMysql } from 'drizzle-orm/mysql2' import { createConnection } from 'mysql2' -import { env } from '../../env.mjs' -if (env.USE_LOCAL_DB !== 'true') { +if (process.env.USE_LOCAL_DB !== 'true') { throw new Error( 'Migrations are only allowed on local database. (this is a custom error)' )