38 Commits

Author SHA1 Message Date
Sebastian Spaeth
6eddc3b75e Move db.sql.open to db.open
Now that mongo has been ripped out and sqlalchemy is already providing
the database abstraction, there is no need to hide everything in the sql
module. Transition db.sql.open to db.open and adapt all direct importers.
2012-12-25 20:09:43 +01:00
Sebastian Spaeth
bc142abc55 RIP out mongo
Since sqlalchemy is providing our database abstraction and we have
moved away from Mongo as the underlying database, it is now time to
simplify things and rip out mongo. This provides the bulk of the
changes, and can stand on its own. There are some followup tasks
that can be done, such as removing now unneeded abstraction layers,
e.g. db.sql.fake.py
2012-12-25 20:06:03 +01:00
Christopher Allan Webber
41fc4698c5 Eeek! Set the migration number to the current migration number being run! 2012-12-09 12:20:06 -06:00
Christopher Allan Webber
a4eef7fe91 Elrond's suggestion: have set_current_migration execute after each migration run. 2012-12-09 12:12:07 -06:00
Sebastian Spaeth
9437ea4742 Add commit argument to clean_orphan_tags
So we can prevent the session from being committed if we don't want it.
2012-11-28 14:43:04 +01:00
Elrond
9abd664bf2 Stop unicode conversion warning during dbupdate.
Just force the passed in name to MigrationManager() to unicode.
2012-11-24 22:57:46 +01:00
Aaron Williamson
be5be1154f Added basic collection functionality 2012-09-18 18:10:36 +02:00
Christopher Allan Webber
35a24fc263 Moving the "dependency injection printer tools" over to tools/common.py 2012-07-14 12:55:14 -05:00
Elrond
07163593ee Create function to search media by slug.
Searching media by slug is easy on mongo. But doing the
joins in sqlalchemy is not as nice. So created a function
for doing it.

Well, and create the same function for mongo, so that it
also works.
2012-03-16 21:20:14 +01:00
Elrond
b62b3b982a Generic check_media_slug_used db utility.
In two cases (generating a new slug and editing the slug)
it is nice to know in advance (before the db gets angry)
that the slug is used/free. So created a db utility
function to check for this on mongo and sql:
check_media_slug_used()
2012-03-05 21:37:05 +01:00
Elrond
c65cbf9514 SQL: Tool to cleanup unused tag slugs.
The current SQL layout/sqlalchemy strucuture can't detect
whether a slug isn't needed any more and delete it. So
provide a tool function to cleanup unused slugs.

It's currently not hooked to any gmg function!
2012-03-05 21:30:39 +01:00
Elrond
325ca444d1 Implement atomic_update for SQL.
On sqlalchemy most updates are atomic enough for most use
cases. Anyway, here is an atomic_update that is compatible
to the mongo version.
2012-03-04 21:05:06 +01:00
Christopher Allan Webber
78d17b8055 Excepting that migration 1 doesn't work(!), sqlalchemy migration branch working
The reason migration 1 doesn't work, and is commented out, is because
of sqlalchemy-migrate not handling certain constraints while dropping
binary sqlite columns right.  See also:
http://code.google.com/p/sqlalchemy-migrate/issues/detail?id=143&thanks=143&ts=1327882242
2012-01-29 22:19:03 -06:00
Christopher Allan Webber
adf5436373 Update the string outputs to match our tests: newlines, ...->:, etc. 2012-01-29 21:45:05 -06:00
Christopher Allan Webber
bff7098a6c migrations_to_run here a list, so no reason to call it 2012-01-29 17:26:23 -06:00
Christopher Allan Webber
9303d47df0 self.latest_migration now a property, so we shouldn't __call__ it! 2012-01-29 17:08:38 -06:00
Christopher Allan Webber
f98be6a65b For clarity, self.database -> self.session.
Actually, I'm not even sure *that* is ideal!  But better than what we
had...
2012-01-29 17:07:47 -06:00
Christopher Allan Webber
ef8591fdd0 Yet *another* self.database -> self.database.bind fix! 2012-01-29 17:06:19 -06:00
Christopher Allan Webber
396f39c3e9 Fix database_current_version for when self.migration_data is None. 2012-01-29 17:05:16 -06:00
Christopher Allan Webber
16d4dce9e9 another db -> db.bind fix. 2012-01-29 17:00:39 -06:00
Christopher Allan Webber
f3791a9490 A few basic fixes to sql/util.py
- MigrationRecord to MigrationData, again
 - If the table doesn't exist, return None for database_current_migration
 - database.engine -> database.bind
2012-01-29 16:58:58 -06:00
Christopher Allan Webber
e8ba2223fa Also switch database_current_migration to a property 2012-01-29 16:40:46 -06:00
Christopher Allan Webber
47616ece50 Make latest_migration a property 2012-01-29 16:36:33 -06:00
Christopher Allan Webber
9a18573190 Import MigrationData, not MigrationRecord 2012-01-29 16:33:47 -06:00
Christopher Allan Webber
cfbbdcc5ad Another db->db.engine because I'm bad at things ;)
Thanks again Elrond.
2012-01-29 16:33:45 -06:00
Christopher Allan Webber
dc5da0f891 Another MigrationManager fix.
self.database -> self.database.engine (thanks again Elrond for the catch)
2012-01-29 16:33:45 -06:00
Christopher Allan Webber
cbf29f2d58 assert was positive when it should be negative, fixed 2012-01-29 16:33:45 -06:00
Christopher Allan Webber
851df6214e Use .first() instead of [0]... thanks elrond :) 2012-01-29 16:33:45 -06:00
Christopher Allan Webber
23f4c6b2fd We should probably add that object to the DB also :P 2012-01-29 16:33:45 -06:00
Christopher Allan Webber
09dcc34c95 Commit that new migration record ;) 2012-01-29 16:33:45 -06:00
Christopher Allan Webber
b0ec21bff3 Add create_new_migration_record method to MigrationManager 2012-01-29 16:33:45 -06:00
Christopher Allan Webber
8bf3f63af1 Added init_tables method to MigrationManager 2012-01-29 16:33:45 -06:00
Christopher Allan Webber
3635ccdf34 More work on SQL MigrationManager
Added methods:
 - migration_data
 - database_current_migration
 - migrations_to_run
2012-01-29 16:33:45 -06:00
Christopher Allan Webber
4c86905789 Removing printer argument now that we use self.printer 2012-01-29 16:33:45 -06:00
Christopher Allan Webber
a315962f0d Finishing the init_or_migrate function 2012-01-29 16:33:45 -06:00
Christopher Allan Webber
705689b96f More work on migration manager, including adding a dry run function 2012-01-29 16:33:45 -06:00
Christopher Allan Webber
def13c549a Beginnings of the SQL migration manager 2012-01-29 16:33:44 -06:00
Christopher Allan Webber
70b44584ae Big ol' start of the SQL migrations system.
Things definitely don't work yet, but should be heading in the right direction.
2012-01-29 16:33:44 -06:00