[Nitro] Fixes to database libs in 0.24 r19

Rob Pitt rob at motionpath.com
Thu Oct 20 09:31:52 EDT 2005


Dimitri Aivaliotis wrote:

> On 10/20/05, *Rob Pitt* <rob at motionpath.com 
> <mailto:rob at motionpath.com>> wrote:
>
>
>     Also, line 221 of lib/og/store/mysql.rb under def create_table(klass):
>
>         There is no proper checking if tables already exist. This is not
>     normally a problem as the mysql library throws an exception and sets
>     $!.errno to 1050 (already exists). However, sometimes  I do not
>     give the
>     db user write access if I just want to read the db with OG
>     resulting in
>     a different error code, 1142 (access deined). You could do something
>     slicker than my one line fix of:
>
>     return if @conn.list_tables.include?(klass::OGTABLE)
>
>     I think this might give a good idea of how this should be done
>     instead?
>
>
> I was always getting tripped up here, too.  Then I realized that 
> there's a parameter that can be set to avoid this:
>
> Og.create_schema = false
>
> - Dimitri
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Nitro-general mailing list
>Nitro-general at rubyforge.org
>http://rubyforge.org/mailman/listinfo/nitro-general
>  
>
Thanks, that could be useful. I still think it should be changed to 
check if the table exists first though as it seems more reasonable and 
also it can be handy to have the create schema on when doing things like:

Og.thread_safe = false/ #stop og exploding/
$drop_table = false
mysql_config = {
  :store => 'mysql',
  :address => 'bender',
  :name => 'mxxx',
  :user => 'migrator',
  :password => 'oldie'
}

psql_config = {
  :store => 'psql',
  :address => 'fry',
  :name => 'mxxx',
  :user => 'nitro',
  :password => 'newone'
}

$DBG = true/ #Debug mode on/

/# Create two Og database objects, one for each database/
psql = Og.connect(psql_config)
mysql = Og.connect(mysql_config)
/# ========> END: Database setup

.................................

//#Manage each class with it's respective database/
mysql.manage(DynamicRdp)
psql.manage(ContentType)
psql.manage(Media)
psql.manage(ImageMedia)
psql.manage(Rdp)
  
/#Perform migration/
ModelMigrator.migrate(DynamicRdp,Rdp,$drop_table)
*end*

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20051020/829abfe2/attachment.html 


More information about the Nitro-general mailing list