Optional [so function_exists()] it?EXreaction wrote:I have a list of phpBB version numbers and the migrations that were applied for those versions. If the migrations table does not exist I automatically fill it with these migrations based on what phpBB version it was.MichaelC wrote:How do you plan to address the problem that is updating from 3.0.x (where x < 12) to 3.1.x that the migrations table would still need adding with the appropriate migrations depending on which version the update is being done from?
Right now I am thinking the safest option might be to add a method to each migration, is_installed, which would be able to run custom code to check if the migration was effectively installed (in which case we'd just add the migration data to the migration table and be done). I think this might be best for us and extension authors who update their mods for 3.1.
[RFC] Migrations
Re: [RFC] Migrations
Formerly known as Unknown Bliss
No unsolicited PMs please except for quotes.psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [RFC] Migrations
The parent would return false, so yes, it would be optional.
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [RFC] Migrations
Currently I am working on documentation in the Wiki. The following are pages I've worked on so far:
https://wiki.phpbb.com/Migrations
https://wiki.phpbb.com/Migrations/Getting_Started
https://wiki.phpbb.com/Migrations/Dependencies
https://wiki.phpbb.com/Migrations/Schema_Changes
https://wiki.phpbb.com/Migrations
https://wiki.phpbb.com/Migrations/Getting_Started
https://wiki.phpbb.com/Migrations/Dependencies
https://wiki.phpbb.com/Migrations/Schema_Changes
Last edited by EXreaction on Sun Jan 13, 2013 2:20 am, edited 1 time in total.
Reason: Added page
Reason: Added page
Re: [RFC] Migrations
Maybe a bit off topic but this doesn't look right to me.
why would someone drop an entire phpBB default table? Wouldn't that then cause issues if a default style is never installed? I may not be thinking completely clearly here as I am sick as a dog (and I have no idea what that even means as dogs rarely get sick as far as I know).
Code: Select all
public function update_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'styles' => array(
'imageset_id',
'template_id',
'theme_id',
),
),
'drop_tables' => array(
$this->table_prefix . 'styles_imageset',
$this->table_prefix . 'styles_imageset_data',
$this->table_prefix . 'styles_template',
$this->table_prefix . 'styles_template_data',
$this->table_prefix . 'styles_theme',
),
);
}
public function revert_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'styles' => array(
'imageset_id' => array('UINT', 0),
'template_id' => array('UINT', 0),
'theme_id' => array('UINT', 0),
),
),
'add_tables' => array(
$this->table_prefix . 'styles_imageset' => array(
'COLUMNS' => array(
'imageset_id' => array('UINT', NULL, 'auto_increment'),
'imageset_name' => array('VCHAR_UNI:255', ''),
'imageset_copyright' => array('VCHAR_UNI', ''),
'imageset_path' => array('VCHAR:100', ''),
),
'PRIMARY_KEY' => 'imageset_id',
'KEYS' => array(
'imgset_nm' => array('UNIQUE', 'imageset_name'),
),
),
$this->table_prefix . 'styles_imageset_data' => array(
'COLUMNS' => array(
'image_id' => array('UINT', NULL, 'auto_increment'),
'image_name' => array('VCHAR:200', ''),
'image_filename' => array('VCHAR:200', ''),
'image_lang' => array('VCHAR:30', ''),
'image_height' => array('USINT', 0),
'image_width' => array('USINT', 0),
'imageset_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'image_id',
'KEYS' => array(
'i_d' => array('INDEX', 'imageset_id'),
),
),
$this->table_prefix . 'styles_template' => array(
'COLUMNS' => array(
'template_id' => array('UINT', NULL, 'auto_increment'),
'template_name' => array('VCHAR_UNI:255', ''),
'template_copyright' => array('VCHAR_UNI', ''),
'template_path' => array('VCHAR:100', ''),
'bbcode_bitfield' => array('VCHAR:255', 'kNg='),
'template_storedb' => array('BOOL', 0),
'template_inherits_id' => array('UINT:4', 0),
'template_inherit_path' => array('VCHAR', ''),
),
'PRIMARY_KEY' => 'template_id',
'KEYS' => array(
'tmplte_nm' => array('UNIQUE', 'template_name'),
),
),
$this->table_prefix . 'styles_template_data' => array(
'COLUMNS' => array(
'template_id' => array('UINT', 0),
'template_filename' => array('VCHAR:100', ''),
'template_included' => array('TEXT', ''),
'template_mtime' => array('TIMESTAMP', 0),
'template_data' => array('MTEXT_UNI', ''),
),
'KEYS' => array(
'tid' => array('INDEX', 'template_id'),
'tfn' => array('INDEX', 'template_filename'),
),
),
$this->table_prefix . 'styles_theme' => array(
'COLUMNS' => array(
'theme_id' => array('UINT', NULL, 'auto_increment'),
'theme_name' => array('VCHAR_UNI:255', ''),
'theme_copyright' => array('VCHAR_UNI', ''),
'theme_path' => array('VCHAR:100', ''),
'theme_storedb' => array('BOOL', 0),
'theme_mtime' => array('TIMESTAMP', 0),
'theme_data' => array('MTEXT_UNI', ''),
),
'PRIMARY_KEY' => 'theme_id',
'KEYS' => array(
'theme_name' => array('UNIQUE', 'theme_name'),
),
),
),
);
Do not hire Christian Bullock he won't finish the job and will keep your money
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [RFC] Migrations
An extension probably should not drop a phpBB table, that is just an example from one case where tables were dropped in a phpBB update. I was trying to show that in revert_schema the table must be recreated.
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [RFC] Migrations
All documentation besides how to use migrations in extensions is complete I believe.
https://wiki.phpbb.com/Migrations
https://wiki.phpbb.com/Migrations/Getting_Started
https://wiki.phpbb.com/Migrations/Dependencies
https://wiki.phpbb.com/Migrations/Schema_Changes
https://wiki.phpbb.com/Migrations/Data_Changes
https://wiki.phpbb.com/Migrations/Tools
https://wiki.phpbb.com/Migrations/Tools/Config
https://wiki.phpbb.com/Migrations/Tools/Module
https://wiki.phpbb.com/Migrations/Tools/Permission
https://wiki.phpbb.com/Migrations/Data_Changes/If
https://wiki.phpbb.com/Migrations/Data_Changes/Custom
https://wiki.phpbb.com/Migrations
https://wiki.phpbb.com/Migrations/Getting_Started
https://wiki.phpbb.com/Migrations/Dependencies
https://wiki.phpbb.com/Migrations/Schema_Changes
https://wiki.phpbb.com/Migrations/Data_Changes
https://wiki.phpbb.com/Migrations/Tools
https://wiki.phpbb.com/Migrations/Tools/Config
https://wiki.phpbb.com/Migrations/Tools/Module
https://wiki.phpbb.com/Migrations/Tools/Permission
https://wiki.phpbb.com/Migrations/Data_Changes/If
https://wiki.phpbb.com/Migrations/Data_Changes/Custom
- nickvergessen
- Former Team Member
- Posts: 733
- Joined: Sun Oct 07, 2007 11:54 am
- Location: Stuttgart, Germany
- Contact:
Re: [RFC] Migrations
The problem I have with this kind of "roll-back" is, that additional columns from other Extensions will be dropped and not restored?EXreaction wrote:An extension probably should not drop a phpBB table, that is just an example from one case where tables were dropped in a phpBB update. I was trying to show that in revert_schema the table must be recreated.
It would making deletes a bit more complicated, but can we just log the table/column structure in the migrations db, so we really have the same state after a rollback?
Member of the Development-Team — No Support via PM
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [RFC] Migrations
That would be true, but I am not sure how to get around it. I do not know how it would be possible to log the structure in the database itself.
The roll-back is intended to bring you back to at least a state that is recognizable and not somewhere in-between. Whatever the issue was that caused the roll-back to occur should be resolved and the update run again.
I guess the ideal situation would be that a database backup is made before an update, but I am not sure if that is something we want to either recommend users do themselves or do automatically for users.
The roll-back is intended to bring you back to at least a state that is recognizable and not somewhere in-between. Whatever the issue was that caused the roll-back to occur should be resolved and the update run again.
I guess the ideal situation would be that a database backup is made before an update, but I am not sure if that is something we want to either recommend users do themselves or do automatically for users.
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [RFC] Migrations
The Migrations documentation is complete I believe, including how to use it in extensions (once the required PR is merged it will work).
-
- Registered User
- Posts: 523
- Joined: Sat Apr 22, 2006 10:29 pm
- Contact:
Re: [RFC] Migrations
That appears to be the right way to go... But do it automatically.EXreaction wrote:... I guess the ideal situation would be that a database backup is made before an update, but I am not sure if that is something we want to either recommend users do themselves or do automatically for users.