Release candidate version: Database migration guide #435
pilcrowonpaper
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Prisma
1. Rename
primary
columnMake sure to update the Prisma schema
SQLite
PostgreSQL
MySQL
2. Rename models
Add
Auth
to model names.3. Rename references
Rename reference names (
user
toauth_session
) and model names within the models (Session[]
toAuthSession[]
).3.5 (Optional). Change table names
You may optionally change the table names mapped to each model with
@@map()
:Make sure update your tables with
ALTER TABLE
before migrating the Prisma schema.SQLite does not fully support foreign keys with
ALTER TABLE
. Refer to Kysely/SQLite section below.4. Migrate Prisma
Mongoose
1. Rename
primary
column2. Rename model name
3. Rename collections
Custom collection names
If you'd like to keep the current name, define the collection name within Mongoose schema with the
collection
option. Do NOT change the model name"auth_user"
.4. Update
auth_key
schemaRename
primary
field toprimary_key
:Extra: Make sure field
auth_key.expires
existsYou can run the following command to set field
expires
tonull
if it doesn't exist.Kysely/SQLite
DO NOT USE
ALTER TABLE
immediately!!!1. Recreate tables with new names
Make sure to also copy custom user attributes. Column
key(primary)
will be renamed later.2. Copy data from old tables
Make sure to start with table
user
/auth_user
.3. Rename
key(primary)
4. Drop old tables
Kysely/MySQL
Kysely/PostgreSQL
Beta Was this translation helpful? Give feedback.
All reactions