Download the PHP package patricknelson/silverstripe-migrations without Composer

On this page you can find all versions of the php package patricknelson/silverstripe-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-migrations

SilverStripe 3.x Database Migrations

Facilitates atomic database migrations in SilverStripe 3.x. Inspired by Laravel's migration capability, this relatively simple module was built to work as an augmentation to the existing dev/build that is already commonplace in SilverStripe.

SilverStripe's database schema is declarative, which means that the code defines what the state of the database currently should be and therefore the system will do what it needs to do in order to change the current schema to match that declared structure at any given moment (by proxy of dev/build). In contrast, database migrations offer a method to imperatively define how that structure (as well as the data) should change progressively over time. The advantage to this is that it makes it easier for you to rename columns (while retaining data), combine multiple columns or even change the format of data over time without leaving behind legacy code which should no longer exist, helping keep things tidy.

Installation

Composer

  1. Run composer require "patricknelson/silverstripe-migrations:dev-master"
  2. Run sake dev/build from the command line to ensure it is properly loaded into SilverStripe.

Manual Installation

  1. Download the latest repository zip file.
  2. Extract the folder silverstripe-migrations-master and rename it migrations.
  3. Copy that folder to the root of your website.
  4. Run sake dev/build from the command line to ensure it is properly loaded into SilverStripe.

How to Use

This module sets up a task called MigrateTask which is available from the command line only via either:

Using this task, you can do the following:

  1. Run migrations (i.e. "up").
    • sake dev/tasks/MigrateTask up
  2. Reverse previous migrations (i.e. "down").
    • sake dev/tasks/MigrateTask down
  3. Make a new migration file for you with boilerplate code.
    • sake dev/tasks/MigrateTask make:migration_name
    • Note: This file will be automatically placed in your project directory in the path <project>/code/migrations. You can customize this location by defining a MIGRATIONS_PATH constant which should be the absolute path to the desired directory (either in your _ss_environment.php or _config.php files). Also, migration files that are automatically generated will be pseudo-namespaced with a Migration_ prefix to help reduce possible class name collisions.

How it Works

Up

Each time you run an up migration, this task will look through all migration files that have been setup in your <project>/code/migrations folder (which you can customize) and then compare that to a list of migrations that it has already run in the DatabaseMigrations table. If it finds a new migration that has not yet been run, it will execute the ->up() method on that migration file and keep a record of it in that table. Also, it will make sure to only run migrations in alphanumeric order based on their file name.

Down

When multiple migrations are run together, they are considered a single batch and can be rolled back (or reversed) all together as well by using the down option. When down migrations are performed, they are done in reverse order one batch at a time to help ensure consistency.

Writing Migrations

You can easily generate migration files by running the task with the make:migration_name option (switching out migration_name with a concise description of your migration using only underscores, letters and numbers).

Example:

sake dev/tasks/MigrateTask make:change_serialize_to_json

This will generate a file following the format YYYY_MM_DD_HHMMSS_change_serialize_to_json.php, using the current date to name the file (to ensure it is executed in order) and containing the class Migration_ChangeSerializeToJson. It should look like this:

A collection of helper methods are also available on the Migration class that perform common database interactions, such as dropping columns from a table or retrieving a value from a column that is no longer available through the ORM but still exists in the database table.

Helper Methods

Documentation for helper methods can be found here.

Running Your Migrations

It's important that before you ever migrate up or down that you make sure you run the SilverStripe dev/build task first. For example, you could do the following:

This will ensure that both the migration classes are available (in the class map) and that the new fields you've declared in your DataObject's are accessible to your migration.

Known Issues

Due to the fact that the existing dev/build process runs independently from these migrations (instead of being based already on migrations), it is possible that you might end up running migrations that are no longer applicable to the given declared state in your current DataObject ::$db static definitions. To help avoid issues in more complex websites, you can either perform checks within the migrations themselves or setup new migrations to coexist with code that is bundled into release branches and deploy them discretely (e.g. release-1.2.0 or hotfix-1.2.1). The primary goal is to ensure that data/content in existing environments can be retained and changed selectively without losing a column, a table or replacing an entire table or database each time your schema has to change.

To Do


All versions of silverstripe-migrations with dependencies

PHP Build Version
Package Version
Requires silverstripe/cms Version ^3.0.0
silverstripe/framework Version ^3.0.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 patricknelson/silverstripe-migrations contains the following files

Loading the files please wait ....