Hi All,

I recently migrated our production database from MySQL to PostgreSQL
and found the existing scripts to be pretty inadequate (and in Perl,
blech).   Lift itself has a lot of cross database smarts built in, and
since I only access the database using models I've defined in my Lift
application, I thought, why not pipe things through mapper?  I threw
together a script which can be used as follows (it should work with
any set of DBs mapper supports):

//**make sure no one is writing to the source database
val fromDbMan = new DbMigrator.SimpleConnManager
("com.mysql.jdbc.Driver","jdbc:mysql://localhost/mydb",Full
("user"),Full("pass"))
val toDbMan = new DbMigrator.SimpleConnManager
("org.h2.Driver","jdbc:h2:~/test;DB_CLOSE_DELAY=-1",None,None)
val batchSize = 1000
DbMigrator.migrate(fromDbMan, toDbMan, batchSize, User, Dog, Employee,
Etc)

println("The counts should be equal: " + User.countDb
(DbMigrator.FromConnectionIdentifier) == User.countDb
(DbMigrator.ToConnectionIdentifier))

git it here: http://gist.github.com/209561

I've tested mysql->postgres and mysql->h2 and h2-> h2 though none of
my tables were bigger than thousands of rows.

- Jon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to