From bc9213cec954fb2bc29213437a33c96f2d0f543c Mon Sep 17 00:00:00 2001 From: Mark Kunzmann Date: Tue, 28 May 2024 15:27:40 +0200 Subject: [PATCH 1/2] Extended User schema --- app/prisma/schema.prisma | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/prisma/schema.prisma b/app/prisma/schema.prisma index 77f2e7a7c3..8244fa5ede 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") From 544706d5451cd1442981178884c921d242e2d61f Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Wed, 29 May 2024 10:20:33 +0200 Subject: [PATCH 2/2] docs: Add bit on migrations & dev database --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d390895bb5..c4037b4a9d 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.