|
|
|
|
|
| Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #44169 is a reply to message #43210 ] |
Fri, 25 January 2008 15:24   |
halfer Messages: 9535 Registered: January 2006 Location: West Midlands, UK |
Faithful Member |
|
|
This is an excellent idea, something that symfony IMO has needed for a long time. I've not tried it yet, but nevertheless, thank you!
PS will it deal with schema.xml files, and schemas within plugins?
[Updated on: Fri, 25 January 2008 15:24] Remember Palestine
|
|
|
|
|
|
| Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #44468 is a reply to message #43210 ] |
Wed, 30 January 2008 18:42   |
gray Messages: 30 Registered: January 2008 |
Member |
|
|
New version has been uploaded.
Changelog:
- added task propel-insert-sql-diff
- fixed php notices
- fixed problem with default values like ''
About fields order in table and AFTER... Symfony user dont work directly with database, but with schema.yml, so i think it isn't important how fields is placed in "real" table.
[Updated on: Wed, 30 January 2008 18:42]
|
|
|
| Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #44601 is a reply to message #44468 ] |
Fri, 01 February 2008 13:28   |
|
I'm currently trying to update my schema using the plugin.
I've encounter one problem and found another small thing that should be changed:
- First of all, the file dbInfo.php uses a short open tag, which should be avoid because the default option in the php.ini file is short_open_tag = Off ;
- The second point is less important but in order to follow the guideline and the naming convention of symfony, the file dbInfo.php should be named dbInfos.class.php
all about me
t-shirts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47203 is a reply to message #47121 ] |
Thu, 06 March 2008 16:27   |
gray Messages: 30 Registered: January 2008 |
Member |
|
|
| Emiliano.Gabrielli wrote on Wed, 05 March 2008 17:20 | I have found a number of very very seriuos bugs related to InnoDB tables:
constraints, indexes and relations often fail on insert due to a number of reasons....
one problem, for example, is the impossibility of DROP and INDEX *if* it is also a FK !!!
|
Yes it is impossible to drop index, if it is used in foreign key.
If you drop both index and foreign key, plugin will generate DROP FOREIGN KEY statement, then DROP INDEX, and all will be ok.
But if you just drop index and create another one with fk column, plugin will not handle it.
I'll try to change it to generate first ADD INDEX and then DROP INDEX, hope it will not break something
|
|
|
| Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47211 is a reply to message #47203 ] |
Thu, 06 March 2008 17:11   |
Emiliano.Gabrielli Messages: 8 Registered: March 2008 Location: Rome |
Junior Member |
|
|
| gray wrote on Thu, 06 March 2008 16:27 |
| Emiliano.Gabrielli wrote on Wed, 05 March 2008 17:20 | I have found a number of very very seriuos bugs related to InnoDB tables:
constraints, indexes and relations often fail on insert due to a number of reasons....
one problem, for example, is the impossibility of DROP and INDEX *if* it is also a FK !!!
|
Yes it is impossible to drop index, if it is used in foreign key.
If you drop both index and foreign key, plugin will generate DROP FOREIGN KEY statement, then DROP INDEX, and all will be ok.
But if you just drop index and create another one with fk column, plugin will not handle it.
I'll try to change it to generate first ADD INDEX and then DROP INDEX, hope it will not break something
|
I found that replacing
ALTER TABLE `t2` DROP KEY `t1_id` ;
ALTER TABLE `t2` ADD INDEX `FK_t1_id` (`t1_id`);
with a single
ALTER TABLE `t2` DROP KEY `t1_id` ,
`t2` ADD INDEX `FK_t1_id` (`t1_id`);
should work!
|
|
|
|
|
|
|
|
|
|
|
| Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #48081 is a reply to message #47455 ] |
Tue, 18 March 2008 16:14   |
gray Messages: 30 Registered: January 2008 |
Member |
|
|
| sumedh wrote on Mon, 10 March 2008 13:01 | I mean, right now it compares the schema.yml with current DB (which would be Dev), right? When developers work on some fetaure, they would change the Dev DB to test the feature...but later on, when we want to go for full QA, we want to make sure all Dev changes are in sync on Stage DB...
Can this plugin help in it?
|
It can help, if all changes where in schema.yml, and it can't help if dev database was changed directly.
But there is some other tools for synchronizing two mysql databases.
[Updated on: Tue, 18 March 2008 16:16]
|
|
|
| Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #48344 is a reply to message #48081 ] |
Mon, 24 March 2008 01:10   |
naholyr Messages: 223 Registered: June 2007 |
Faithful Member |
|
|
Very useful plugin, it solves a quite simple but every-day annoying issue, especially during development (losing all the test-data everytime is very boring ><).
I easily accept it cannot support renaming (how could it ?), and it's really good for me.
But your lib/dbInfo.php file uses short_tags ! this is evil, causing the output of the class in CLI, and because of that i always start my projects whining against this 
Please fix this ^^
By the way, you could provide this new task I now always use insteda of propel-build-all && cc 
pake_desc('rebuild model and upgrade database');
pake_task('propel-update-all',
'app_exists', // 0. Pre-requisites
'propel-build-model', // 1. Rebuild model
'propel-insert-sql-diff', // 3. generate and insert SQL
'clear-cache' // 4. Clear cache
);
|
|
|
| Small fix for code [message #48371 is a reply to message #43210 ] |
Mon, 24 March 2008 11:37   |
yspro Messages: 19 Registered: March 2008 Location: Belarus::Minsk |
Junior Member |
|
|
In dbInfo.php class find method "getDiffWith" and replace the rows between "//drop, alter index" and "//drop, alter field":
<?php //drop, alter index
if($tabledata['keys'])
foreach($tabledata['keys'] as $field=>$fielddata) {
$otherdata = @$db_info2->tables[$tablename]['keys'][$field];
$ind_name = @$otherdata['type']=='PRIMARY'?'PRIMARY KEY':"{$otherdata['type']} INDEX";
$diff_ar = array_diff($fielddata['fields'],$otherdata['fields']);
$difference = (empty($diff_ar)) ? FALSE : TRUE;
if($fielddata['code'] and !$otherdata['code']) {
if($fielddata['type']=='PRIMARY') {
$diff_sql .= "ALTER TABLE `$tablename` DROP PRIMARY KEY;\n";
} else {
$diff_sql .= "ALTER TABLE `$tablename` DROP INDEX $field;\n";
}
} elseif($difference || $fielddata['type']!=$otherdata['type']) { //fixed by [YS.PRO]
if($this->debug) {
$diff_sql .= "/* old definition: {$fielddata['code']}\n new definition: {$otherdata['code']} */\n";
}
if($fielddata['type']=='PRIMARY') {
$diff_sql .= "ALTER TABLE `$tablename` DROP PRIMARY KEY;\n"; //ok
} else {
$diff_sql .= "ALTER TABLE `$tablename` DROP INDEX $field;\n";
}
$diff_sql .= "ALTER TABLE `$tablename` ADD $ind_name ".($field?"`$field`":"")." {$otherdata['code']};\n";
}
} ?>
[Updated on: Mon, 24 March 2008 11:38] [YS.PRO] blog
|
|
|
|