diff --git a/README.md b/README.md index d390895bb..c4037b4a9 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ yarn dev:rollup #### Database migrations -Database migrations are run automatically when the _production_ app starts. In _development_, you'll have to run them manually: +Database migrations are run automatically when a production build of the app starts. In _development_, you'll have to run them manually: ```sh yarn db:migrate:dev @@ -94,6 +94,18 @@ Migrations are located in `db-migrations/`. Write SQL or JS migrations and follo For detailed instructions, please refer to the [postgres-migrations](https://github.com/thomwright/postgres-migrations) documentation. +⚠️ On Vercel environments like "preview" and "production", "production" build are started which means that database migrations are executed. +Since all environments are sharing the same database, it means that a database migration executing on 1 database could be disruptive to +other preview deployments. For example adding a column to the schema would be disruptive, since other preview deployments would try to +remove it (since the column is not yet in the schema). To prevent any problems on preview deployments, we have a second database that +is special for development and that must be used if you are working on a branch that brings in database changes. You can configure +this in the Vercel environment variables by copy-pasting the environment variables found in the [visualization-tool-postgres-dev][] +storage (see `.env.local` tab), and copy paste them as [environment variables](https://vercel.com/ixt/visualization-tool/settings/environment-variables) +in the visualisation-project. Take care of scoping the new environment variables to the preview branch you are working on. +After merging the branch, you can delete the environment variables scoped to the branch. + +[visualization-tool-postgres-dev](https://vercel.com/ixt/visualization-tool/stores/postgres/store_dV3rog1asOXO3BfC/data) + ## Versioning New versions of `package.json` are built on GitLab CI into a separate image that will be deployed to the integration env. diff --git a/app/prisma/schema.prisma b/app/prisma/schema.prisma index 77f2e7a7c..8244fa5ed 100644 --- a/app/prisma/schema.prisma +++ b/app/prisma/schema.prisma @@ -32,6 +32,10 @@ model User { id Int @id @default(autoincrement()) sub String? @unique @db.VarChar(64) name String? @db.VarChar(100) + last_login DateTime? @db.Timestamp(6) + created_at DateTime @default(now()) @db.Timestamp(6) + updated_at DateTime @default(now()) @db.Timestamp(6) + Config Config[] @relation() @@map("users")