Jump to content

RockMigrations - Easy migrations from dev/staging to live server (AND MUCH MORE!!)


Recommended Posts

v0.0.63

Thx to the feedback of @wbmnfktr I've made it a lot easier to get started with RockMigrations!

The readme has now a dedicated quickstart section: https://github.com/BernhardBaumrock/RockMigrations#quickstart

The example that was shipped with RockMigrations was also improved. I removed some complexity and used real world example names (a simple blog setup) instead of "foo" and "bar". This should make it a lot easier to understand 🙂 

Also I improved the page name replacements feature introduced lately: Page name replacements now ship with the module. They are saved in a dedicated folder and named "de.txt" for german replacements. If you need any other replacement options just let me know! (maybe @apeisa ? )

$rm->setPagenameReplacements("de");

https://github.com/BernhardBaumrock/RockMigrations/tree/master/replacements

  • Like 4
Link to post
Share on other sites
  • 5 weeks later...

I love the module! 

I was wondering how do you handle creating a page reference field when the templates and pages are created in the same migration. Because you don't know the id's yet.

'fields' => [
	'pageSelect' => [
		'type' => 'page',
        'template_id' => XX, //template ID (foo-template to be created)
        'parent_id' => XX // Parent ID (parent-foo to be created),
        'inputfield' => 'InputfieldAsmSelect',
 	],
 ],

'templates' => [
    'foo-template',
	'parent-foo-template',
 ],

 

  • Like 1
Link to post
Share on other sites

If execution order is important you can always use the declarative syntax:

$p1 = $rm->createPage(...);
$p2 = $rm->createPage(...);
$p2->setAndSave('pageref', $p1);

does that help?

Link to post
Share on other sites
1 minute ago, bernhard said:

If execution order is important you can always use the declarative syntax:


$p1 = $rm->createPage(...);
$p2 = $rm->createPage(...);
$p2->setAndSave('pageref', $p1);

does that help?

Kind of

How would it work for field settings?

Link to post
Share on other sites
$rm->setFieldData(...)

Best docs we have so far is using intellisense of your IDE and looking into the code 🙂 

gbWV4Tk.png

Link to post
Share on other sites
1 minute ago, bernhard said:

$rm->setFieldData(...)

Best docs we have so far is using intellisense of your IDE and looking into the code 🙂 

gbWV4Tk.png

🙌 thanks

Link to post
Share on other sites

v0.0.64 adds a new method

$rm->createViewFile('yourtemplate');

that creates a file /site/templates/yourtemplate.php

That might sound like overkill, but when used with class constant and OOP that makes it clear and easy:

<?php namespace RockTeam;

use ProcessWire\Page;
use ProcessWire\RockMigrations;
use ProcessWire\RockTeam;

class TeamPage extends Page {

  const prefix = RockTeam::prefix;
  const tpl = self::prefix."teampage";
  const tags = RockTeam::tags;

  /**
   * Triggered in RockTeam::migrate()
   */
  public function migrate(RockMigrations $rm) {
    $rm->migrate([
      'templates' => [
        self::tpl => [
          'tags' => self::tags,
          'icon' => 'users',
          'fields' => ['title'],
        ],
      ],
    ]);
    $rm->createViewFile(self::tpl);
  }

}

 

  • Like 2
Link to post
Share on other sites

Hi Ivan,

good question 🙂 My workflow is based on RockUikit - a module for Frontend Development similar to WireFrame. So I need the file solely for making the site visible on the frontend. Markup is placed in a different location. Now that you are asking I realize that this might not be the most helpful addition for others. Anyhow I'm just keeping you updated so maybe someone will pick up some inspiration or have suggestions or input for me 🙂 

But in general my workflow is now a little bit like "everything is a module" 😅 And RockMigrations does everything related to template/field/page creation 🙂 

  • Like 1
Link to post
Share on other sites

Most of the time I do not have anything in template file other than the namespace too as I use it as a controller. And unlike Wireframe I do need this file to avoid error, so this is not useless addition.

  • Like 1
Link to post
Share on other sites

Actually it already has a second parameter to provide a file to take the content from. This means you could add a skeleton folder to your module holding the initial markup and the module will copy that content to the templates folder: https://github.com/BernhardBaumrock/RockMigrations/blob/3844b697be393b98dbc9a47b55370c4fa521c20b/RockMigrations.module.php#L1817

One could also make it sync files or add the file having a single "include" to reference the markup from within a module folder. But I didn't want to overcomplicate things 🙂 

  • Like 1
Link to post
Share on other sites

That's nice! It could be useful to allow adding not only template files, but any files (like my views) to make it complete. A basis for scaffolding feature development as well.

Link to post
Share on other sites

You can set any file that exists and is readable on your server already...

$rm->createViewFile("mytemplate.php", "/path/to/your/source/file.php");

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...