550 Commits

Author SHA1 Message Date
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
780fdd7bd6 import changeset into sql models 2012-01-29 16:33:46 -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
bf81382896 Make name the primary key in migration records 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
Elrond
51fba99125 Some small SQL model improvements
- Add default for User.email_verified
- Add default for MediaEntry.state
- Let PathTupleWithSlashes store [] as "NULL",
  but not handling the reverse properly yet!
- Add _id alias field to MediaEntry and MediaComment
2012-01-29 23:02:40 +01:00
Elrond
de91730336 Nearly complete support for Tags
These changes allow all of the rest of the code to use tags
in sql as they were used on mongo. It's not efficient at
all, as changing tags usually means to remove all old tags
and adding all new.

The only problem here is: Old slugs for tags are not
removed, because they're shared across all MediaTags and
dropping orphans is not always easy.
2012-01-28 19:32:43 +01:00
Elrond
d7bec8577e Add develover sql switch
If you want to play with the current state of sql, you need
a switch to turn it on. So here is the super secret
developer switch.

So you want to know where it is?

Here it is:

Create a file mediagoblin/db/sql_switch.py and put one line
in it: "use_sql = True" (or False to disable again). Right,
that's it. If you want to delete it, remember to delete the
*.pyc too.

Be careful not to "git add" it by accident!
2012-01-28 18:36:44 +01:00
Elrond
3e907d5516 Let some code support "media without slug"
The upcoming SQL database will allow having media without a
slug again. This might especially be useful for API
support, where the uploaded image (media) does not have
*any* information to generate a slug from.

This code change mostly allows the sql backend to have no
slug in its model and improves some parts to properly
handle that.

It specifically does not have any web frontend support to
edit/create MediaEntries with no slug.
2012-01-28 13:53:55 +01:00
Elrond
3c43cfc9f9 Move declarative_base Base into base.py
The base class of all models "Base" should be in base.py.
2012-01-26 23:07:39 +01:00
Elrond
c47a03b909 Proper url_to_{prev,next} for SQL
Uses complete sqlalchemy syntax now.
2012-01-22 18:41:06 +01:00
Elrond
02ede85826 Create a fully functional get_comments for SQL
Using proper sqlalchemy syntax instead of the emulated
mongo one.
2012-01-22 18:40:42 +01:00
Christopher Allan Webber
ac014f0424 Convert over the license field, too! 2012-01-21 16:41:07 -06:00
Christopher Allan Webber
2788e6a164 License "all rights reserved" default should be None/NULL, not empty string 2012-01-21 16:40:39 -06:00
Aaron Williamson
c8035da197 Added migration for license field, resolved conflict in db/sql/models.py 2012-01-19 22:00:08 -05:00
Elrond
fbad3a9fb9 Add copyright header and a bit of pep8ification
Nearly all the sql files missed a copyright header.
So added it!
And while there fixed a few pep8 things.
2012-01-20 00:17:05 +01:00
Elrond
92edc74e9b Use custom query class
A custom query class allows to add more methods on
queries (read: "cursors").

This custom query class especially adds a .sort with a
calling convention exactly like the mongo one.
Makes a lot of existing code happy!
2012-01-20 00:00:57 +01:00
Aaron Williamson
17c23e15e4 Moved get_license_data to mixin.py, added license to sql media model, added translation tags to license template. 2012-01-18 21:07:55 -05:00
Aaron Williamson
291e24f397 Merge branch 'mediagoblin-upstream' into feature544_basic_license_data 2012-01-18 20:40:18 -05:00
Elrond
6fc8af3278 sql/fake.py: Some fake objects/methods to calm the code
sql/fake.py contains some fake classes and functions to
calm the rest of the code base. Or provide super minimal
implementations.

Currently:
- ObjectId "class": It's a function mostly doing
  int(first_arg) to convert string primary keys into
  integer primary keys.
- InvalidId exception
- DESCENING "constant"
2012-01-18 23:35:55 +01:00
Aaron Williamson
a6c49d49dc Fixed a syntax error in edit/views and added back in some missing license stuff from models 2012-01-17 01:22:02 -05:00
Aaron Williamson
25bdf9b657 Fixed merge with upstream 2012-01-17 01:05:15 -05:00
Aaron Williamson
99a270e952 Merged changes with upstream 2012-01-17 00:59:21 -05:00
Aaron Williamson
25b48323a8 First crack at basic license support. 2012-01-17 00:33:55 -05:00
Elrond
02db7e0a83 Add MediaFile table and related infrastructure.
- This adds a new SQL table field type for path tuples.
  They're stored as '/' separated unicode strings.

- Uses it to implement a MediaFile table.

- Add relationship and proxy fields on MediaEntry to give a
  nice media_files "view" there.

- Let the converter fill the MediaFile.
2012-01-11 12:19:03 +01:00
Elrond
cb7ae1e433 Fix url_for_self mixup
Move changes from mongo/models:url_for_self back into
mixin:url_for_self.
2012-01-11 11:16:35 +01:00
Christopher Allan Webber
73079ac4b8 Merge branch 'master' of gitorious.org:mediagoblin/mediagoblin
Conflicts:
	mediagoblin/db/mongo/models.py
2012-01-10 08:12:30 -06:00