logto
logto copied to clipboard
feat(schemas): add migrations table
Summary
Add a new table migrations
, prepare to be used for migrations.
The table name is started with underscore _
since it is a special table and irrelevant to other business.
Brief introduction of the plan on migrations:
- We'll create a migration file each time we change our db structure. This file will contain JS code to change the db structure and migrate data if needed.
- Compare files and db's
_migrations
table, find the migration files need to run for the current db. - Run the files.
The migration steps MUST run with exact order, so add checksums to ensure that the history file is not been modifid.
COMPARE TO master
Total Size Diff :chart_with_upwards_trend: +266 Bytes
Diff by File
Name | Diff |
---|---|
packages/schemas/tables/migrations.sql | :chart_with_upwards_trend: +266 Bytes |
What data and when will this data be persisted in this table?
Assume that we have 3 new migration files:
- 1658921424_add_user_created_at
- 1658922424_add_application_secret
- 1658923424_change_app_id_to_client_id
Then when the migration begins, these 3 files will be run in sequence, and inserting 3 rows in the table.
And next time, we can skip those files according the this table's rows.
@demonzoo FYI
This PR is stale because it has been open 10 for days with no activity. Remove stale label or comment or this will be closed in 5 days.