aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/sql
Commit message (Collapse)AuthorAgeFilesLines
* Add MediaFile table and related infrastructure.Elrond2012-01-113-3/+49
| | | | | | | | | | | | - 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.
* Add DB Mixin classes and use themElrond2012-01-081-2/+3
| | | | | | | | | | | | | | | A bunch of functions on the db objects are really more like "utility functions": They could live outside the classes and be called "by hand" passing the appropiate reference. They usually only use the public API of the object and rarely use database related stuff. Goals: - First, simple: Share the code with the SQL objects, so that the code doesn't need to be duplicated. - Second, it might unclutter the db models and make them more into "model only" stuff. - Doesn't really hurt.
* sql convert: Use more library functionsElrond2012-01-011-11/+9
| | | | | | | | | | 1. Use the new setup_connection_and_db_from_config in the sql backend. 2. Use sql and mongo specific functions wherever appropiate instead of the generic "db.X" one. This makes the converter more indepedent of the current backend choice.
* Factor out check_db_migrations_currentElrond2012-01-011-0/+4
| | | | | | | | | | When initializing the database connection the current mongo based setup checked for new migrations and warned about them. This was mongo specific so factor'd it out into a more generic check_db_migrations_current function in the mongo backend. Also created a dummy one in the sql backend.
* Add a .save method on the sql db objectsElrond2011-12-291-1/+9
| | | | | | | | This is a shortcut to adding the object to a session (if needed) and giving a commit on the session. In reality, calling code should probably utilize the session on its own and call commit in an appropiate place.
* Support .get(fieldname) on sql db objectsElrond2011-12-291-0/+3
| | | | | | Some parts of the code like to call .get("somefield") on the db objects. It's easy to support this on sqlalchemy based objects, so lets do it.
* SQL Model: Add relationship propertiesElrond2011-12-281-0/+5
| | | | | | MediaEntry now has a get_uploader (property) loading the appropiate User object for the MediaEntry (and caches it). MediaComment has the same for author as get_author.
* SQL Model: Forgot MediaEntry.state fieldElrond2011-12-282-1/+2
| | | | | | | | While creating the new SQL model, the "state" field of MediaEntry was left out. Currently using a plain unicode string for it. Maybe should use sqlalchemy.types.Enum?
* Implement _id proxy on sql objects (on User for now)Elrond2011-12-281-0/+14
| | | | | | | | So that the old code can access the primary key still as "._id". Quite simple Python Descriptor thing. Very generic.
* Improve .one() by using sqlalchemy's .one()Elrond2011-12-241-3/+1
|
* Add search level one() methodElrond2011-12-241-0/+13
| | | | And create a _fix_query_dict which converts '_id' to 'id'.
* SQL: mongokit like interfaceElrond2011-12-184-2/+54
| | | | | | | | In trying to ease the migration to SQL, created an interface to sqlalchemy that looks a lot like the interface that is currently in use. *WARNING* Work in progress
* Simple Mongo -> SQL migration toolElrond2011-12-171-0/+143
| | | | | | | | | | | | | | | | This is just a start at a Migration tool from Mongo to SQL. It fills all currently available SQL models with data from MongoDB. A few fields in the SQL tables are left out, because some data format migrations are needed (notably: queue_file_name). This thing lives in mediagoblin/db/sql/convert.py because it has a lot of stuff hardcoded and is not, repeat not for end users! Hard coded: - output database: ./mediagoblin.db (sqlite) - Mediagoblin config: ./mediagoblin.ini
* Little sql model updateElrond2011-12-171-1/+2
| | | | | | - Add title to the MediaEntry - Rename fp_verification_expire to fp_token_expire to follow the mongo model.
* SQL: Some toys and little fixElrond2011-12-151-1/+12
| | | | | | | | Run bin/python mediagoblin/db/sql/models.py and watch the create tables on a memory sqlite db. Also unicode strings need unicode defauls. Warning by sqlalchemy.
* Move sql models into db/sql/Elrond2011-12-152-0/+110
So we can play with the sql models, let's put them in a proper place.