Database Migrations

本文介绍了在数据库模型发生变化时如何使用自定义的Sequelize迁移策略进行数据库迁移。内容包括创建迁移文件的命名规范和结构,以及应用迁移的过程。特别强调了在写迁移时要注意确保可逆性,并谨慎处理添加约束的情况,以防导致平台启动失败或需要手动干预。
摘要由CSDN通过智能技术生成

It is important that any changes made to the database models include migrations that can modify the database state from one state to another.

Whilst we use Sequelize as our ORM layer, we do not use the migration tooling it provides - we have our own.

Creating migrations

Filename

A migration is provided as a JavaScript in the directory forge/db/migrations. Its file name must follow the pattern:

YYYYMMDD-nn-description.js
  • YYYYMMDD - the date the migration is added
  • nn - a two digit number
  • description - a name for the migration

For example 20220204-01-add-billing.js.

This ensures the migrations have a natural order to be applied. The nn part of the name allows multiple migrations to be added on the same day, but kept in the right order.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值