363 Commits

Author SHA1 Message Date
Elrond
1582181701 mongo to sql convert: Better Ordering
Order the conversion by the "created" attribute. That way
the sql ids are mostly in the order they would have been,
if sql was used earlier.

Makes things nicer to look at in a db dump.
2012-02-23 23:44:13 +01:00
Christopher Allan Webber
3ea1cf36fc Updates so that dbupdate command works
- Various fixes to dbupdate itself
 - Switching db/sql/migrations.py to use a dict instead of a list
 - Registering the function
2012-02-18 23:19:09 -06:00
Christopher Allan Webber
4d8be4fe0d Merge branch 'master' into sqlmigrate 2012-02-18 15:33:29 -06:00
Elrond
a45631e3f3 Start having useful defaults for SQL
Mostly this means: Havintg a config_spec.ini that has a
local (relative to mediagoblin.ini) sqlite db with the name
"mediagoblin.db".

Also:
- Add to .gitignore
- Add a notice to mediagoblin.ini about the db
2012-02-18 19:34:11 +01:00
Elrond
6456cefa0d Fix MediaTag __init__ to handle no args
Let the init code also handle createing a fresh clean
instance without any attrs set.
2012-02-18 19:34:11 +01:00
Elrond
cf27accc9e SQL: fail_metadata as JSON encoded field
fail_metadata used to be a dict in mongo. So a json encoded
field should be okay too.

We could use a pickled field instead, which would be more
flexible.
2012-02-18 19:29:01 +01:00
Christopher Allan Webber
63352aaf70 Merge branch 'master' into sqlmigrate
Conflicts:
	mediagoblin/db/sql/models.py
2012-02-18 10:01:47 -06:00
Elrond
feba5c5287 Drop pre-rendered html: MediaComment.content_html
After a bit of discussion, we decided to drop the
pre-rendered html from the database and render it on
the fly.

In another step, we will use some proper caching method to
cache this stuff.

This commit affects the MediaComment.content_html part.
2012-02-18 12:50:30 +01:00
Elrond
1e72e075f8 Drop pre-rendered html: MediaEntry.description_html
After a bit of discussion, we decided to drop the
pre-rendered html from the database and render it on
the fly.

In another step, we will use some proper caching method to
cache this stuff.

This commit affects the MediaEntry.description_html part.
2012-02-18 12:41:25 +01:00
Elrond
e61ab0998b Drop pre-rendered html: User.bio_html
After a bit of discussion, we decided to drop the
pre-rendered html from the database and render it on
the fly.

In another step, we will use some proper caching method to
cache this stuff.

This commit affects the User.bio_html part.
2012-02-18 12:35:30 +01:00
Elrond
eea6d276bc sql db design suggestions by Svavar Kjarrval
Many thanks go to Svavar Kjarrval who has taken a deeper
look at our current sql db design and made a bunch of
suggestions.  The suggestions are currently put as TODO
items in the docstrings.  This way we can keep track of
them directly where we need it.
2012-02-11 12:11:51 +01:00
Will Kahn-Greene
7f4ebeed76 Fix copyright statements; add LICENSE for EXIF.py 2012-02-08 10:47:08 -05:00
Christopher Allan Webber
cf29e8a824 It's 2012 all up in here 2012-02-02 09:44:13 -06: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
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