TypeRocket v1 Pro users can now upgrade to TypeRocket v5 at their convenience.
Migrations
( v1 )
- # Setting Up Migrations
- # Logging and Storing Migrations
- # Admin UI
- # Make Migration
- # Migrate Up
- # Migrate Down
- # Migrate Flush
- # Migrate Reload
Setting Up Migrations
The TypeRocket migration system requires having WordPress command support to TypeRocket Galaxy. Once you ensure WordPress commands are available you will see the make migration command make:migration
.
Note: Local VM machines will need to make sure the CLI has access to the guest and host machines.
Logging and Storing Migrations
TypeRocket migrations are stored in the file system under the database/migrations
folder. TypeRocket goes about migrations this way because WordPress does not have a standard migrations system.
When a migration is run it creates a database entry in the wp_options
table with the key tr_migrations
.
Note: PRO migrations are stored in the database. This allows for multi-server configurations.
Admin UI
You can view the status of your migrations using the DevTools extension in your WordPress admin on the Dev page under the migrations tab.
Make Migration
To make a migration run, the make:migration
Galaxy command with a "name" for that migration.
php galaxy make:migration add_blocks_table
Then, in the migration file, add the SQL for your migration. Under the >>> Up >>>
section add the SQL for migrating up or forward. Under the >>> Down >>>
section add the SQL for migrating down or backward.
Anywhere you add {
the migration system will replace {
with your WordPress table prefix (the default is wp_
).
-- Description: For reusable page builder components
-- >>> Up >>>
CREATE TABLE IF NOT EXISTS `{Pro Only FeatureprefixPro Only Feature}blocks` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`blocks` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- >>> Down >>>
DROP TABLE `{Pro Only FeatureprefixPro Only Feature}blocks`;
Migrate Up
To migrate "up" and run all migrations that have not yet been run use the command migrate up
.
php galaxy migrate up
You can also specify how many migrations you would like to run. For example, to run just one migration you could do the following:
php galaxy migrate up 1
Migrate Down
To migrate "down" and drop down one migration that has already been run use the command migrate down
.
php galaxy migrate down
You can also specify how many migrations you would like to run. For example, to run just three migrations you could do the following:
php galaxy migrate down 3
Migrate Flush
Migrate "down" all migrations that have been run.
php galaxy migrate flush
Migrate Reload
Migrate "down" all migrations that have been run and then migrate "up".
php galaxy migrate reload
Found a typo? Something is wrong in this documentation? Fork and edit it!