[Erp5-report] r33938 rafael - in /erp5/trunk/utils/erp5.recipe.mysqldatabase: ./ src/erp5/r...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Mar 19 21:37:42 CET 2010


Author: rafael
Date: Fri Mar 19 21:37:42 2010
New Revision: 33938

URL: http://svn.erp5.org?rev=33938&view=rev
Log:
Introduced new parameter "mysql_force_recreation" to force database recreation if it already exists.

Modified:
    erp5/trunk/utils/erp5.recipe.mysqldatabase/README.txt
    erp5/trunk/utils/erp5.recipe.mysqldatabase/src/erp5/recipe/mysqldatabase/__init__.py

Modified: erp5/trunk/utils/erp5.recipe.mysqldatabase/README.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqldatabase/README.txt?rev=33938&r1=33937&r2=33938&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqldatabase/README.txt [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.mysqldatabase/README.txt [utf8] Fri Mar 19 21:37:42 2010
@@ -44,3 +44,6 @@
 mysql_superpassword
   Password of user defined at mysql_superuser.
 
+mysql_force_recreation
+  If "true" the database is recreated (Dropped and created), even this
+  exists before. By default uses false. 

Modified: erp5/trunk/utils/erp5.recipe.mysqldatabase/src/erp5/recipe/mysqldatabase/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqldatabase/src/erp5/recipe/mysqldatabase/__init__.py?rev=33938&r1=33937&r2=33938&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqldatabase/src/erp5/recipe/mysqldatabase/__init__.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.mysqldatabase/src/erp5/recipe/mysqldatabase/__init__.py [utf8] Fri Mar 19 21:37:42 2010
@@ -33,6 +33,8 @@
 
     options.setdefault('mysql_port', '3306')
 
+    options.setdefault('mysql_force_recreation', "false")
+
   def install(self):
     options = self.options
     location = options['location']
@@ -62,6 +64,10 @@
     )
     connection.autocommit(0)
     cursor = connection.cursor()
+
+    if options.get("mysql_force_recreation", "false").lower() == "true":
+       cursor.execute( "DROP DATABASE IF EXISTS %s" % database_name)
+
     cursor.execute(
       'CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET utf8 COLLATE '
       'utf8_unicode_ci' % database_name)




More information about the Erp5-report mailing list