This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » General plug-ins » new plugin sfPropelSqlDiffPlugin - build diff sql
new plugin sfPropelSqlDiffPlugin - build diff sql [message #43210] Thu, 10 January 2008 18:58 Go to next message
gray  is currently offline gray
Messages: 30
Registered: January 2008
Member
Hi

sfPropelSqlDiff plugin generate diff.sql file, which contains difference beetween schema.yml and current database structure.

It provides new symfony task - propel-build-sql-diff which will create file diff.sql with ALTER TABLE statements, whitch will make current database structure exactly as it described schema.yml without deleting data in tables as it does propel-build-sql task.

http://trac.symfony-project.com/wiki/sfPropelSqlDiffPlugin

Comments, bugreports and paches are wellcome Smile
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #43271 is a reply to message #43210 ] Fri, 11 January 2008 21:21 Go to previous messageGo to next message
Mob[st]er  is currently offline Mob[st]er
Messages: 11
Registered: August 2007
Junior Member
#1 THe idea is GREAT ! Congratulations ! Thank you for doing this !

#2 I found many bugs Sad

Amongst those bugs:

Notice: Undefined index: fkeys in C:\mywebprojects\project\plugins\sfPropelSqlDiffP
lugin\lib\dbInfo.php on line 219

Notice: Undefined index: fkeys in C:\mywebprojects\project\plugins\sfPropelSqlDiffP
lugin\lib\dbInfo.php on line 233


Using symfony version 1.0.11-PRE on windows XP with wamp

It creates the diff file but I'm just afraid to use it as I don't want to screw up my DB ..
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #43297 is a reply to message #43271 ] Sat, 12 January 2008 21:30 Go to previous messageGo to next message
gray  is currently offline gray
Messages: 30
Registered: January 2008
Member
Mob[st

er wrote on Fri, 11 January 2008 21:21]
Amongst those bugs:

Notice: Undefined index: fkeys in C:\mywebprojects\project\plugins\sfPropelSqlDiffP
lugin\lib\dbInfo.php on line 219


Well, in my php configuration, notices are disabled... Ok, i'll fix it.
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #43735 is a reply to message #43297 ] Fri, 18 January 2008 18:59 Go to previous messageGo to next message
Mob[st]er  is currently offline Mob[st]er
Messages: 11
Registered: August 2007
Junior Member
Hello again,

I wanted to thank you again for the plugin, i've been looking for something exactly like that for a couple of months now Wink THe only thing I found before that was http://syncsql.com/ .

Also, I wanted to know if you had some time to fix these errors ?

THanks again !

P.S. Think should be included in 1.1 directly !
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #44148 is a reply to message #43735 ] Thu, 24 January 2008 23:29 Go to previous messageGo to next message
gray  is currently offline gray
Messages: 30
Registered: January 2008
Member
Mob[st

er wrote on Fri, 18 January 2008 18:59]Also, I wanted to know if you had some time to fix these errors ?


I am going to fix it and release 0.1.1 version next week

Mob[st

er wrote on Fri, 18 January 2008 18:59]
P.S. Think should be included in 1.1 directly !


This plugin can't be included in 1.1. It isn't yet stable. It is tested only for mysql.
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #44169 is a reply to message #43210 ] Fri, 25 January 2008 15:24 Go to previous messageGo to next message
halfer  is currently offline 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 #44172 is a reply to message #43210 ] Fri, 25 January 2008 15:38 Go to previous messageGo to next message
Mob[st]er  is currently offline Mob[st]er
Messages: 11
Registered: August 2007
Junior Member
Hello again gray !

THanks for the update ! Also, I don't know if it's related to the current but but it appears that when you add a field to the yml file and then you run de sqldiff, the diff.sql generated contains the new fields BUT it doesn't contain the "location" on where to add the field.

Example:
ALTER TABLE test ADD 'some_field'
instead of
ALTER TABLE test ADD 'some_field' AFTER 'some_other_field'

Is it just me ?

Regards
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #44175 is a reply to message #43210 ] Fri, 25 January 2008 15:57 Go to previous messageGo to next message
michael.piecko  is currently offline michael.piecko
Messages: 624
Registered: June 2006
Location: Germany
Faithful Member
Hmm. "ALTER ... AFTER ...", it is not common SQL, isn't it?

Michael
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #44176 is a reply to message #43210 ] Fri, 25 January 2008 16:04 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Avoid AFTER if you can. The x-platform way to re-order table elements is to rename the table, rename constraints, recreate the table, recreate the constraints for the new table, and copy the data across. However this is a bit involved, so I'd recommend not implementing this until the current version is stable Smile


Remember Palestine
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #44468 is a reply to message #43210 ] Wed, 30 January 2008 18:42 Go to previous messageGo to next message
gray  is currently offline 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 Go to previous messageGo to next message
nautilebleu  is currently offline nautilebleu
Messages: 281
Registered: June 2006
Location: Caen, France
Faithful Member

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:

  1. 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 ;
  2. 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 #45294 is a reply to message #44601 ] Mon, 11 February 2008 16:15 Go to previous messageGo to next message
Dincho  is currently offline Dincho
Messages: 14
Registered: July 2007
Junior Member
Hi, excellent idea for plugin! Thanks!

But something going wrong here:
>> propel-sql-diff building database patch

                                          
  [SQLException]                          
  Invalid resultset column: Create Table                                       


Symfony 1.0.11@LAMP

All common propel builders works fine.
Also i have try this after and before some schema changes, but same result.
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #45296 is a reply to message #45294 ] Mon, 11 February 2008 17:13 Go to previous messageGo to next message
gray  is currently offline gray
Messages: 30
Registered: January 2008
Member
Dincho wrote on Mon, 11 February 2008 16:15


But something going wrong here:
>> propel-sql-diff building database patch
                                          
  [SQLException]                          
  Invalid resultset column: Create Table                                       




I think you have something specific in schema.yml. If you share it (if it isn't secret) i will try to fix it.
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #45298 is a reply to message #43210 ] Mon, 11 February 2008 17:21 Go to previous messageGo to next message
gray  is currently offline gray
Messages: 30
Registered: January 2008
Member
The problem is because it can't find column "Create Table"
in query result
show create table <tablename>
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #45304 is a reply to message #45298 ] Mon, 11 February 2008 17:56 Go to previous messageGo to next message
Dincho  is currently offline Dincho
Messages: 14
Registered: July 2007
Junior Member
Why this forum have no PM ? Sad
Please drop me an empty mail to:

$str = 'dincho xbuv com';
str_replace(' ', '.', $str); Very Happy

I do not want to share my schema to public, sorry
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #46619 is a reply to message #43210 ] Thu, 28 February 2008 00:38 Go to previous messageGo to next message
skyblaze  is currently offline skyblaze
Messages: 205
Registered: January 2008
Faithful Member
anyone using this plugin right now? is it good/stable enough?
icon5.gif  Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #46928 is a reply to message #46619 ] Mon, 03 March 2008 10:49 Go to previous messageGo to next message
klemens_u  is currently offline klemens_u
Messages: 18
Registered: September 2007
Location: Vienna, Austria
Junior Member
Hello!

It seems like sfPropelSqlDiffPlugin is missing?!?

I can't install it via symfony plugin-install nor via subversion.

Any reason for this?

Wink Klemens
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #46937 is a reply to message #43210 ] Mon, 03 March 2008 13:11 Go to previous messageGo to next message
gray  is currently offline gray
Messages: 30
Registered: January 2008
Member
You can try

symfony plugin-install http://plugins.symfony-project.com/sfPropelSqlDiffPlugin-0.1 .1

There is some issues with version i suppose.
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #46946 is a reply to message #46937 ] Mon, 03 March 2008 15:05 Go to previous messageGo to next message
klemens_u  is currently offline klemens_u
Messages: 18
Registered: September 2007
Location: Vienna, Austria
Junior Member
Thanks!

(a note on the wiki page regarding the version thing wouldn't hurt!)

btw: while testing sfPropelSqlDiffPlugin I noticed that the plugin is using the files in data/sql. It happened in my place, that there where some old files form previous 'propel-build-sql' (I suppose). The result was a messed up diff file. I had to delete these files to get a proper result. Could this be done automatically by calling propel-build-sql-diff?

Thanks for your effort!

Wink Klemens
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #46951 is a reply to message #46946 ] Mon, 03 March 2008 15:31 Go to previous messageGo to next message
gray  is currently offline gray
Messages: 30
Registered: January 2008
Member
klemens_u wrote on Mon, 03 March 2008 15:05

Could this be done automatically by calling propel-build-sql-diff?



Well, yes. It could be included in future version, or you can try to do it yourself Wink
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #46956 is a reply to message #44601 ] Mon, 03 March 2008 17:12 Go to previous messageGo to next message
Emiliano.Gabrielli  is currently offline Emiliano.Gabrielli
Messages: 8
Registered: March 2008
Location: Rome
Junior Member
nautilebleu wrote on 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:

  1. 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 ;
  2. 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



I can confirm the importance of these points, the second one raising an exception for me (dbInfo class not found)
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #46957 is a reply to message #43210 ] Mon, 03 March 2008 17:19 Go to previous messageGo to next message
Emiliano.Gabrielli  is currently offline Emiliano.Gabrielli
Messages: 8
Registered: March 2008
Location: Rome
Junior Member
I was testing this very useful plugin, but I encountered a big big problem:

I'm used to divide my schema into a number of files, one for each macro feature I implement .. so in may case I have :

config/
schema.yml
profiling-schema.yml
toponomastic-schema.yml

and so on ..

Well, at the moment I run the symfony task schmaS and DB were quite in sync , *but* the sesulting diff.sql was a number of terrific

DROP TABLE !!

I think the plugin do not takes into account the files I mentioned, but symfony does, so it is to be considered as a plugin's bug
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #46959 is a reply to message #46957 ] Mon, 03 March 2008 17:36 Go to previous messageGo to next message
klemens_u  is currently offline klemens_u
Messages: 18
Registered: September 2007
Location: Vienna, Austria
Junior Member
Hi Emiliano,

try deleting everything in data/sql (backup first!).
Then run again propel-build-sql-diff

Does it help?

Wink Klemens
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #46973 is a reply to message #46959 ] Mon, 03 March 2008 18:45 Go to previous messageGo to next message
Emiliano.Gabrielli  is currently offline Emiliano.Gabrielli
Messages: 8
Registered: March 2008
Location: Rome
Junior Member
I had hust tryed of course .. nope!
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47004 is a reply to message #43210 ] Tue, 04 March 2008 12:04 Go to previous messageGo to next message
Emiliano.Gabrielli  is currently offline Emiliano.Gabrielli
Messages: 8
Registered: March 2008
Location: Rome
Junior Member
Found the bug at least !!

The plugin has troubles with schema using a "description:" field

 89     privacy:
 90       type: CHAR
 91       size: 4
 92       required: true
 93       default: "0000"
 94 #      description: "Bitmask rappresentante i consensi dati (generale,f,g,h)"
 95     auth_code:
 96       type: CHAR
 97       size: 32
 98       default: NULL
 99 #      description: "Codice di autorizzazione per l'attivazione o la modifica della password"
100     _uniques:
101       UNIQUE_email:


commenting out the "description" lines makes everything working nice !!
So this is a bug, plz try to fix it Smile


[Updated on: Wed, 05 March 2008 09:04]

Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47121 is a reply to message #43210 ] Wed, 05 March 2008 17:20 Go to previous messageGo to next message
Emiliano.Gabrielli  is currently offline Emiliano.Gabrielli
Messages: 8
Registered: March 2008
Location: Rome
Junior Member
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 !!!
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47203 is a reply to message #47121 ] Thu, 06 March 2008 16:27 Go to previous messageGo to next message
gray  is currently offline 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 Smile
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47211 is a reply to message #47203 ] Thu, 06 March 2008 17:11 Go to previous messageGo to next message
Emiliano.Gabrielli  is currently offline 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 Smile



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 #47286 is a reply to message #47004 ] Fri, 07 March 2008 12:02 Go to previous messageGo to next message
Emiliano.Gabrielli  is currently offline Emiliano.Gabrielli
Messages: 8
Registered: March 2008
Location: Rome
Junior Member
Emiliano.Gabrielli wrote on Tue, 04 March 2008 12:04

Found the bug at least !!

The plugin has troubles with schema using a "description:" field

 89     privacy:
 90       type: CHAR
 91       size: 4
 92       required: true
 93       default: "0000"
 94 #      description: "Bitmask rappresentante i consensi dati (generale,f,g,h)"
 95     auth_code:
 96       type: CHAR
 97       size: 32
 98       default: NULL
 99 #      description: "Codice di autorizzazione per l'attivazione o la modifica della password"
100     _uniques:
101       UNIQUE_email:


commenting out the "description" lines makes everything working nice !!
So this is a bug, plz try to fix it Smile






I found another BUG in comments handling:

if on the DB there is a comment containing parentheses, such as ")", it breaks the preg_match around line 45 of the class ...

plz try to fix it too Smile
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47361 is a reply to message #43210 ] Sat, 08 March 2008 08:20 Go to previous messageGo to next message
sumedh  is currently offline sumedh
Messages: 6
Registered: March 2008
Junior Member
Hi,

I am not being able to get this to work. Everything else in my symfony and propel is working fine.

When I execute "symfony propel-build-sql-diff frontend", it first executes schema generation, and writes to lib.model.schma.sql, but then throws following error...

>> file- /home/sumedh/workspace/zam_fe/config/generated-schema.xml
>> propel-sql-diff building database patch

Warning: Cannot modify header information - headers already sent by (output started at /home/sumedh/workspace/zam_fe/plugins/sfPropelSqlDiffPlugin/ data/tasks/sfPropelSqlDiffTask.php:16) in /usr/share/php/symfony/exception/sfException.class.php on line 101

[exception] sfFileException
[message] Unable to open the log file "/home/sumedh/workspace/zam_fe/log/frontend_dev.log" for writing
[stack trace]

at () in SF_SYMFONY_LIB_DIR/log/sfLogger/sfFileLogger.class.php line 44
at sfFileLogger->initialize(array('file' =&gt; '/home/sumedh/workspace/zam_fe/log/frontend_dev.log')) in SF_ROOT_DIR/cache/frontend/dev/config/config_logging.yml.php line 24
at include('/home/sumedh/workspace/zam_fe/cache/frontend/dev/co nfig/config_logging.yml.php') in SF_SYMFONY_LIB_DIR/symfony.php line 90
at require('/usr/share/php/symfony/symfony.php') in SF_SYMFONY_LIB_DIR/util/sfCore.class.php line 55
at sfCore::callBootstrap() in SF_SYMFONY_LIB_DIR/util/sfCore.class.php line 33
at sfCore::bootstrap('/usr/share/php/symfony', '/usr/share/php/data/symfony') in SF_ROOT_DIR/apps/frontend/config/config.php line 8
at require_once('/home/sumedh/workspace/zam_fe/apps/frontend/co nfig/config.php') in SF_ROOT_DIR/plugins/sfPropelSqlDiffPlugin/data/tasks/sfPrope lSqlDiffTask.php line 29

My log file has rwx permissions for everyone...not sure why it mentions log file problem...

Any advice?
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47429 is a reply to message #47361 ] Mon, 10 March 2008 09:16 Go to previous messageGo to next message
Emiliano.Gabrielli  is currently offline Emiliano.Gabrielli
Messages: 8
Registered: March 2008
Location: Rome
Junior Member
sumedh wrote on Sat, 08 March 2008 08:20

Hi,

[exception] sfFileException
[message] Unable to open the log file "/home/sumedh/workspace/zam_fe/log/frontend_dev.log" for writing



Your log file is not writeable by the user you are using to run the task (you are in the cli interface, so you are not "apache" ... double check your permissions and try run "symfony fix-perms"
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47432 is a reply to message #47429 ] Mon, 10 March 2008 09:57 Go to previous messageGo to next message
sumedh  is currently offline sumedh
Messages: 6
Registered: March 2008
Junior Member
Hi,

The log file is accessible for writing to all...

I also ran symfony fix-perms as you said...

But still getting the same error... Sad

My other symfony tasks are writing to the same log file properly...so may be permissions is not the problem?

Thanks in advance...
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47449 is a reply to message #43210 ] Mon, 10 March 2008 12:44 Go to previous messageGo to next message
cokker  is currently offline cokker
Messages: 582
Registered: January 2007
Location: Germany
Faithful Member
Have you tried to delete log file so it get newly created?

greets
Sven
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47450 is a reply to message #47449 ] Mon, 10 March 2008 12:49 Go to previous messageGo to next message
sumedh  is currently offline sumedh
Messages: 6
Registered: March 2008
Junior Member
Yup...it worked...

But I wonder why... Sad

I mean the log file is working fine for everything else...and it has rwx permission for everyone...

thanks any way...
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47453 is a reply to message #43210 ] Mon, 10 March 2008 12:54 Go to previous messageGo to next message
cokker  is currently offline cokker
Messages: 582
Registered: January 2007
Location: Germany
Faithful Member
I think this has to do with caching of file-stats inside PHP.

http://www.php.net/manual/en/function.clearstatcache.php

greets
Sven
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #47455 is a reply to message #47450 ] Mon, 10 March 2008 13:01 Go to previous messageGo to next message
sumedh  is currently offline sumedh
Messages: 6
Registered: March 2008
Junior Member
Yup...permission caching would be the issue I suppose...thanx...

BTW, the next question is, how can I use this plugin to sync my Stage DB with my Dev DB?

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?

Thanks in advance...
Re: new plugin sfPropelSqlDiffPlugin - build diff sql [message #48081 is a reply to message #47455 ] Tue, 18 March 2008 16:14 Go to previous messageGo to next message
gray  is currently offline 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 Go to previous messageGo to next message
naholyr  is currently offline 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 Razz
Please fix this ^^

By the way, you could provide this new task I now always use insteda of propel-build-all && cc Wink
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 Go to previous messageGo to next message
yspro  is currently offline 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
Re: Small fix for code [message #48376 is a reply to message #48371 ] Mon, 24 March 2008 12:31 Go to previous messageGo to previous message
gray  is currently offline gray
Messages: 30
Registered: January 2008
Member
yspro wrote on Mon, 24 March 2008 11:37

In dbInfo.php class find method "getDiffWith" and replace the rows between "//drop, alter index" and "//drop, alter field":



This patch will ignore fields order in keys? Fields order in keys is important, if you want to speedup execution of some queries. For example multiple index key1(field1, field2) can act as single key index key2(field1), but can't as key3(field2)
Previous Topic:sfDoctrineGuardUser - newbee question
Next Topic:generate doctrine admin to a plugin directory
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software