logto icon indicating copy to clipboard operation
logto copied to clipboard

feat(schemas): add migrations table

Open wangsijie opened this issue 2 years ago • 4 comments

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:

  1. 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.
  2. Compare files and db's _migrations table, find the migration files need to run for the current db.
  3. Run the files.

The migration steps MUST run with exact order, so add checksums to ensure that the history file is not been modifid.

wangsijie avatar Jul 27 '22 06:07 wangsijie

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

github-actions[bot] avatar Jul 27 '22 06:07 github-actions[bot]

What data and when will this data be persisted in this table?

charIeszhao avatar Jul 27 '22 08:07 charIeszhao

Assume that we have 3 new migration files:

  1. 1658921424_add_user_created_at
  2. 1658922424_add_application_secret
  3. 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

wangsijie avatar Jul 27 '22 12:07 wangsijie

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.

github-actions[bot] avatar Aug 12 '22 02:08 github-actions[bot]