dcardon / play-migrate Goto Github PK
View Code? Open in Web Editor NEWDatabase version migration module for use in the Play! framework
Database version migration module for use in the Play! framework
Created patch files 28.up.myGroupPatch.sql and 28.down.myGroupPatch.sql
Ran migrate:up
Received:
Collision list:
/home/server/db/migrate/incapsula_stage1/28.down.proxyGroupActivation.sql <==> /home/server/db/migrate/incapsula_stage1/28.up.proxyGroupActivation.sql
Seems like commands.py has a bug in line 135 - the regular expression pattern '/up.sql' is too weak. It catches the "up" part of the work "Group" in the filename 28.down.proxyGroupActivation.sql, which is a downgrade patch.
Should be changed to something stronger, like: r'/\d+.up*.sql'
I use one db - PostgreSQL 9.2.9
For example, the migration script may be file with name 13.up.failure_test.sql with line: SELECT 1 FROM a;. Table a
does not exist.
Output:
~/play1-1.2.7.2/play migrate:up
~ _ _
~ _ __ | | __ _ _ | |
~ | ' | |/ ' | || ||
~ | /|_|__|__ ()
~ || |__/
~
~ play! 1.2.7.2, http://www.playframework.org
~
~ Database migration:
~
~ Database: umbrella_mastodon (Alias:db1)
Execution: psql -U postgres -h 10.65.67.232 -p 5432 -t -d umbrella_mastodon -f /data/projects/umbrella/tmp/migrate.module/check_version.sql
~ Version: 12
~ Status: | Successful
~ Max patch version: 13
~
~ Migrating...
Execution: psql -U postgres -h 10.65.67.232 -p 5432 -t -d umbrella_mastodon -f /data/projects/umbrella/db/migrate/db1/13.up.failure_test.sql
~ 13...
Execution: psql -U postgres -h 10.65.67.232 -p 5432 -t -d umbrella_mastodon -f /data/projects/umbrella/tmp/migrate.module/update_version.sql
~
~ Migration completed successfully
~
~ ------------------------------------
~
db.properties files collides with hsql filesystem database files (db.properties for instance). one cannot therefore use the fs in test mode as well as th migrate module.
Cheers
If your application has multiple db's defined in the conf file, only the first db in the list will be updated if there is a space between the names. For example, if the conf file looks like:
"migrate.module.dbs=db1, db2"
patches for db2 will not be run. the database will be created but the patches aren't run. However if you modify the conf file to look like:
"migrate.module.dbs=db1,db2"
it works great. Creating both dbs and running the patches for both.
glenjr
Hi everyone,
I don't know if this module is still maintained, but I found an issue with the name matching.
Example file name: 10.down.update_test.sql
When calling migrate:up
the search_path in line 153 unfortunately matches the above file name which then later can't be matched by the regex matcher.
This leads to this exception:
Traceback (most recent call last):
File "...\play-1.5.1\play", line 159, in <module>
status = cmdloader.commands[play_command].execute(command=play_command, app=play_app, args=remaining_args, env=play_env, cmdloader=cmdloader)
File "...\play1app\modules\migrate-1.4\commands.py", line 425, in execute
up()
File "...\play1app\modules\migrate-1.4\commands.py", line 340, in up
[maxindex, files_obj] = getMigrateFiles(db_alias,int(version))
File "...\play1app\modules\migrate-1.4\commands.py", line 163, in getMigrateFiles
index = int(match.group(1))
AttributeError: 'NoneType' object has no attribute 'group'
153 search_path = os.path.join(app.path, 'db/migrate/',dbname + '/*.up*.sql')
154
155 initial_list = glob.glob(search_path)
156 return_obj = {}
157 collisions = []
158 # Filter the list to only the specified pattern
159 pat = re.compile('(\d+)\.up.*\.sql\Z')
160 maxindex = 0
161 for file in initial_list:
162 match = re.search(pat,file)
163 index = int(match.group(1))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.