Skip to content

Conversation

elia
Copy link
Member

@elia elia commented Apr 1, 2025

This pull request introduces a migration framework for the Shopify Toolkit, enabling the management of migrations through a set of commands and supporting classes. The key changes include adding command-line tasks for migrations, implementing a Migration base class, and creating a Migrator class to handle migration execution and metadata management.

Command-line enhancements:

  • Added new commands (migrate, down, redo) to run migrations up, down, or redo them, utilizing the ShopifyToolkit::Migrator class. (lib/shopify_toolkit/command_line.rb, lib/shopify_toolkit/command_line.rbR56-R73)

Migration framework:

  • Introduced a ShopifyToolkit::Migration base class with methods for defining up and down migrations, logging, and handling migration directions. (lib/shopify_toolkit/migration.rb, lib/shopify_toolkit/migration.rbR1-R63)
  • Added error handling for irreversible migrations via a custom IrreversibleMigration exception. (lib/shopify_toolkit/migration.rb, lib/shopify_toolkit/migration.rbR1-R63)

Migration execution and metadata management:

  • Created a ShopifyToolkit::Migrator class to load, execute, and manage migrations, including metafield-based storage of migrated versions for tracking state. (lib/shopify_toolkit/migrator.rb, lib/shopify_toolkit/migrator.rbR1-R152)
  • Implemented MigrationProxy to defer loading of migration classes until needed, improving efficiency and modularity. (lib/shopify_toolkit/migrator.rb, lib/shopify_toolkit/migrator.rbR1-R152)

@elia elia self-assigned this Apr 1, 2025
@elia elia force-pushed the elia/migrations branch from 5ca17b4 to 82041f0 Compare April 2, 2025 14:48
@elia elia force-pushed the elia/migrations branch from 82041f0 to ce1a5c8 Compare April 11, 2025 14:37
@elia elia changed the title Add support for treating Metafield and Metaobject definitions as a database schema Add support for treating Metafield/Metaobject definitions as a database schema Apr 11, 2025
@elia elia force-pushed the elia/migrations branch 2 times, most recently from ecb7dbb to f80fd7e Compare May 2, 2025 08:44
@elia elia force-pushed the elia/migrations branch from f80fd7e to f46384d Compare May 26, 2025 15:23
@elia elia marked this pull request as ready for review May 26, 2025 15:25
@elia elia force-pushed the elia/migrations branch 2 times, most recently from a0fd1ac to a7a1e16 Compare May 27, 2025 11:09
Detach from database migrations. This solves a number of problems
where a dev db was reset while the dev shopify app already had its
metafields defined. Also using ShopifyApp the app token is stored
within the db itself, putting the migrations in a deadlock if run
from an empty db.

Co-Authored-By: Alberto Vena <kennyadsl@gmail.com>
Co-Authored-By: Marco Arduini <mar.arduini@gmail.com>
Co-Authored-By: Gianluca Elia <34285663+gianlukk994@users.noreply.github.com>
Co-Authored-By: Nicolò Rebughini <nicolo.rebughini@gmail.com>
@elia elia force-pushed the elia/migrations branch from a7a1e16 to ad47eea Compare May 27, 2025 11:19
@elia elia merged commit b34c836 into main May 27, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant