[PR #876] [MERGED] feat: new migration system #835

Closed
opened 2026-02-25 23:35:37 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-shiori/shiori/pull/876
Author: @fmartingr
Created: 4/6/2024
Status: Merged
Merged: 4/27/2024
Merged by: @fmartingr

Base: masterHead: feat/migrations


📝 Commits (10+)

  • 525f5de feat: new migration system
  • a14e9bc use newFuncMigration
  • 04bea9f database version -> database schema version
  • c9707fd column name
  • 7b98627 use path instead of filepath for goembed
  • 0f8762a simplified migrations, added backwards compatible migrations
  • 74e9399 Merge branch 'master' into feat/migrations
  • d412a99 Merge branch 'master' into feat/migrations
  • 6d5d5e1 Merge remote-tracking branch 'origin/master' into feat/migrations
  • 0de4246 Merge branch 'master' into feat/migrations

📊 Changes

33 files changed (+392 additions, -301 deletions)

View changed files

📝 go.mod (+2 -17)
📝 go.sum (+5 -163)
📝 internal/cmd/root.go (+1 -1)
📝 internal/database/database.go (+10 -5)
internal/database/migrations.go (+97 -0)
internal/database/migrations/mysql/0000_system_create.up.sql (+3 -0)
internal/database/migrations/mysql/0000_system_insert.up.sql (+1 -0)
📝 internal/database/migrations/mysql/0001_initial_account.up.sql (+1 -0)
internal/database/migrations/mysql/0002_initial.up.sql (+0 -14)
internal/database/migrations/mysql/0002_initial_bookmark.up.sql (+15 -0)
📝 internal/database/migrations/mysql/0003_initial_tag.up.sql (+0 -0)
📝 internal/database/migrations/mysql/0004_initial_bookmark_tag.up.sql (+0 -0)
internal/database/migrations/mysql/0005_config.down.sql (+0 -1)
internal/database/migrations/mysql/0005_config.up.sql (+0 -2)
internal/database/migrations/postgres/0000_system.up.sql (+5 -0)
📝 internal/database/migrations/postgres/0001_initial.up.sql (+13 -11)
internal/database/migrations/postgres/0002_config.down.sql (+0 -1)
internal/database/migrations/postgres/0002_config.up.sql (+0 -2)
internal/database/migrations/sqlite/0000_system.up.sql (+5 -0)
📝 internal/database/migrations/sqlite/0001_initial.up.sql (+2 -0)

...and 13 more files

📄 Description

This pull request removes the golang-migrate dependency for a new custom migration system. This new system will leverage existing files but will add the possibility of running Golang code as a migration for portability.

Changes:

  • Removes golang-migrate
  • Adds methods to the DB interface:
    • GetDatabaseSchemaVersion: Retrieves the database schema version
    • SetDatabaseSchemaVersion: Sets the database schema version
    • DBx: returns the underlying dbx.DB object.
  • DB.Migrate now requires a context.Context
  • Moved the database driver imports to their respective package files
  • Simplified all current changes into single migrations (except for MySQL). Added a backwards compatible migration for upgrades to ensure users that haven't run all migrations have the new columns present.

Caveats:

  • Migrations can't go backwards. System can be implemented but in reality this is not likely to happen. The idea is to make migrations backwards compatible (not removing/changing columns). We will see.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-shiori/shiori/pull/876 **Author:** [@fmartingr](https://github.com/fmartingr) **Created:** 4/6/2024 **Status:** ✅ Merged **Merged:** 4/27/2024 **Merged by:** [@fmartingr](https://github.com/fmartingr) **Base:** `master` ← **Head:** `feat/migrations` --- ### 📝 Commits (10+) - [`525f5de`](https://github.com/go-shiori/shiori/commit/525f5de147dca583820ff5f80407d687d2875c91) feat: new migration system - [`a14e9bc`](https://github.com/go-shiori/shiori/commit/a14e9bcdae46a9701e945fb85ad7e4be3c8016a0) use newFuncMigration - [`04bea9f`](https://github.com/go-shiori/shiori/commit/04bea9f601d23259d7bc0efe2e30c48fb514c543) database version -> database schema version - [`c9707fd`](https://github.com/go-shiori/shiori/commit/c9707fdb9e4faeb8e3210c0b41642e1b7bc54b07) column name - [`7b98627`](https://github.com/go-shiori/shiori/commit/7b986272ed2350b12f2ed94ef0803f5e5d444ce7) use path instead of filepath for goembed - [`0f8762a`](https://github.com/go-shiori/shiori/commit/0f8762aa46ddcf3068a5eb6af0d969753f7476ba) simplified migrations, added backwards compatible migrations - [`74e9399`](https://github.com/go-shiori/shiori/commit/74e93999a816628c403252e9431ca4f66d7c6eb6) Merge branch 'master' into feat/migrations - [`d412a99`](https://github.com/go-shiori/shiori/commit/d412a99ba3d3e9c00ae7bd689a455984057c7317) Merge branch 'master' into feat/migrations - [`6d5d5e1`](https://github.com/go-shiori/shiori/commit/6d5d5e15f9f69cfac4b89807bd6a74083b086a6e) Merge remote-tracking branch 'origin/master' into feat/migrations - [`0de4246`](https://github.com/go-shiori/shiori/commit/0de4246c7ac0ba05538d7f652f316bb26eda2542) Merge branch 'master' into feat/migrations ### 📊 Changes **33 files changed** (+392 additions, -301 deletions) <details> <summary>View changed files</summary> 📝 `go.mod` (+2 -17) 📝 `go.sum` (+5 -163) 📝 `internal/cmd/root.go` (+1 -1) 📝 `internal/database/database.go` (+10 -5) ➕ `internal/database/migrations.go` (+97 -0) ➕ `internal/database/migrations/mysql/0000_system_create.up.sql` (+3 -0) ➕ `internal/database/migrations/mysql/0000_system_insert.up.sql` (+1 -0) 📝 `internal/database/migrations/mysql/0001_initial_account.up.sql` (+1 -0) ➖ `internal/database/migrations/mysql/0002_initial.up.sql` (+0 -14) ➕ `internal/database/migrations/mysql/0002_initial_bookmark.up.sql` (+15 -0) 📝 `internal/database/migrations/mysql/0003_initial_tag.up.sql` (+0 -0) 📝 `internal/database/migrations/mysql/0004_initial_bookmark_tag.up.sql` (+0 -0) ➖ `internal/database/migrations/mysql/0005_config.down.sql` (+0 -1) ➖ `internal/database/migrations/mysql/0005_config.up.sql` (+0 -2) ➕ `internal/database/migrations/postgres/0000_system.up.sql` (+5 -0) 📝 `internal/database/migrations/postgres/0001_initial.up.sql` (+13 -11) ➖ `internal/database/migrations/postgres/0002_config.down.sql` (+0 -1) ➖ `internal/database/migrations/postgres/0002_config.up.sql` (+0 -2) ➕ `internal/database/migrations/sqlite/0000_system.up.sql` (+5 -0) 📝 `internal/database/migrations/sqlite/0001_initial.up.sql` (+2 -0) _...and 13 more files_ </details> ### 📄 Description This pull request removes the `golang-migrate` dependency for a new custom migration system. This new system will leverage existing files but will add the possibility of running Golang code as a migration for portability. Changes: - Removes **golang-migrate** - Adds methods to the `DB` interface: - `GetDatabaseSchemaVersion`: Retrieves the database schema version - `SetDatabaseSchemaVersion`: Sets the database schema version - `DBx`: returns the underlying `dbx.DB` object. - `DB.Migrate` now requires a `context.Context` - Moved the database driver imports to their respective package files - Simplified all current changes into single migrations (except for MySQL). Added a backwards compatible migration for upgrades to ensure users that haven't run all migrations have the new columns present. Caveats: - Migrations can't go backwards. System can be implemented but in reality this is not likely to happen. The idea is to make migrations backwards compatible (not removing/changing columns). We will see. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-25 23:35:37 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shiori#835
No description provided.