Download the PHP package restruct/silverstripe-database-migrations without Composer

On this page you can find all versions of the php package restruct/silverstripe-database-migrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package silverstripe-database-migrations

SilverStripe Database Migrations

Database migration utilities for SilverStripe 5.
Handles table renames, classname value remapping, and column renames during dev/build.

Migrations applied during dev/build

Features

Usage

DataObject Migrations

Add legacy mappings directly to your DataObjects:

Config-based Migrations

For join tables, versioned tables, or other non-DataObject tables:

Running Migrations

Migrations run automatically before SilverStripe processes any schema updates.

How ClassName Remapping Works

SilverStripe stores the fully-qualified class name in a ClassName column for polymorphic queries. When you rename or move a class, existing database records still reference the old class name:

Without remapping, SilverStripe cannot instantiate these records because the old class no longer exists.

What happens during dev/build:

  1. The extension collects mappings from:

    • $legacy_classnames on each DataObject
    • classname_mappings config (for cases where you can't modify the class)
  2. Injects them into SilverStripe's built-in DatabaseAdmin.classname_value_remapping

  3. SilverStripe runs UPDATE queries to fix the values:

After remapping:

When to use $legacy_classnames vs classname_mappings config

Use $legacy_classnames on your DataObject when:

Use classname_mappings in YAML config when:

Common use cases:

How Table Migrations Work

The extension hooks into DatabaseAdmin::onBeforeBuild() and renames tables before SilverStripe processes schema updates.

Conflict handling: If both old and new tables exist:

How Table Merges Work

Table merges handle the case where you're consolidating two block types (or similar DataObjects) into one. This is different from a simple rename because the target table already has its own data.

Use case: Merging BlockBanner into BlockHero with a "banner" style variation:

What happens during dev/build:

  1. onBeforeBuild (before schema):

    • ClassName remapping → BlockBanner records now have ClassName = 'BlockHero'
    • Column renames → BannerImageID becomes HeroImageID
  2. Schema build (SilverStripe):

    • Creates/updates BlockHero table structure
  3. onAfterBuild (after schema):
    • Table merge:
      • Inserts BlockBanner records that don't exist in BlockHero
      • Updates existing BlockHero records where columns are empty
      • Sets Element.Style = 'banner-style' on migrated records
      • Handles _Live and _Versions tables if versioned: true
      • Moves BlockBanner tables to _obsolete_BlockBanner (with counter suffix if already exists)

Marker field: The marker config is useful for:

After Migrations: Cleanup Options

Once migrations have successfully run on all environments (dev, staging, production), you have two options:

Option 1: Remove migration config (recommended for one-time migrations)

After deployment, you can safely remove:

The migrations are idempotent (they check if old tables/values exist before acting), so keeping them has no functional impact. However, removing them:

Option 2: Keep migration config (recommended for distributed systems)

You may want to keep migration config in place when:

Performance impact: Minimal. The extension iterates through DataObject classes once during dev/build to collect mappings. Table/column checks only run if mappings are found, and bail out early if old tables/columns don't exist.

Hybrid approach

Keep migration config during a transition period, then remove it in a future release once all environments are confirmed migrated.

License

MIT


All versions of silverstripe-database-migrations with dependencies

PHP Build Version
Package Version
Requires silverstripe/framework Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package restruct/silverstripe-database-migrations contains the following files

Loading the files please wait ...