aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/sql
Commit message (Collapse)AuthorAgeFilesLines
* First migration fix: commit after each migration.Elrond2012-06-141-0/+2
| | | | | | | | | | | | sqlite doesn't like complex changes (alter table) to happen inside a transaction that has already done other things. And really, each migration should say "I'm done" and commit its changes. This is not the full story, but it's the core of it. Specifially the migration framework should probably do a rollback "just in case" after each migration.
* FIXED SQL MIGRATION #2Joar Wandborg2012-06-102-3/+5
|
* Added SQL migrations for email notificationsJoar Wandborg2012-06-101-2/+14
|
* Merge remote-tracking branch ↵Joar Wandborg2012-06-101-0/+1
|\ | | | | | | | | | | | | 'is_derek/bug405_email_notifications_for_comments' into notifications-merge Conflicts: mediagoblin/db/mongo/migrations.py
| * Merge branch 'master' into derek-moore-bug405_email_notifications_for_commentsChristopher Allan Webber2012-03-183-16/+107
| |\ | | | | | | | | | | | | Conflicts: mediagoblin/db/mongo/migrations.py
| * | Added wants_comment_notification to sql modelDerek Moore2012-03-151-0/+1
| | |
* | | added support for original audio download; renameJakob Kramer2012-05-201-1/+19
| | | | | | | | | | | | Renamed `ogg' to `webm_audio' in core__file_keynames
* | | Cleanup sql session after request. ALWAYS!Elrond2012-04-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The cleanup could be missed if the request handling code in app.py:__call__ exits early (due to exception, or due to one of those early "return"s). So to make sure the sql session is cleaned up for real, wrap the whole thing in a try: finally:. Also wrote a short tool to test if the session is actually empty. The tool is currently disabled, but ready to be used.
* | | Check that the media_data tables are empty.Elrond2012-04-021-1/+8
| | | | | | | | | | | | | | | In the analyzing part also check that the media_data tables are empty (as expected) before dropping them.
* | | Add ascii and audio tables/migration data.Elrond2012-04-022-1/+23
| | | | | | | | | | | | Well, and if it's not needed, drop it again. ;)
* | | Cleanup unused media_data tables and migration info.Elrond2012-04-021-6/+34
| | | | | | | | | | | | | | | | | | After converting everything, check what is actually used in the db. For media_types that are not used, drop all the media_data tables and remove the migration info.
* | | Mongo -> SQL conversion tool: UI improvementsElrond2012-04-021-16/+28
| | | | | | | | | | | | | | | | | | Output some headers while converting things. And indent some info. Also some DRY things.
* | | Fixed an issue where orphaned comments breaks the importJoar Wandborg2012-04-021-5/+11
| | |
* | | Switch JSONEncoded from VARCHAR to TEXTElrond2012-04-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | The JSON fields are really "dumb stuff in here" fields. They are not intended to get indexed or anything. And they can get large. For example the exif_all field in one of my simple tests is nearly 7 kB large. Although VARCHAR might work, TEXT feels just better as the storage type.
* | | And remove some now useless methods.Elrond2012-03-291-36/+0
| | |
* | | Remove the DictReadProxy thing.Elrond2012-03-291-47/+4
| | | | | | | | | | | | And some other stuff, that the converter does not need.
* | | Fix some simple errors.Elrond2012-03-292-4/+5
| | |
* | | Change models to a _v0 suffix.Elrond2012-03-292-48/+50
| | | | | | | | | | | | | | | And add the image and video media_data tables. And start to rewrite the convert tool.
* | | Make a copy of models for v0.Elrond2012-03-291-0/+375
| | |
* | | Cleanup mongo->sql converter.Elrond2012-03-251-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | 1. No need to drop media_data['exif'], we only have and want media_data['exif_all']. 2. Use media['_id'] instead of media._id (better not use dot-notation on mongo objects in such a low level tool).
* | | New media_data row needs to know its MediaEntry's id.Elrond2012-03-221-1/+2
| | | | | | | | | | | | | | | | | | | | | When creating a new media_data row, the new row needs to know the MediaEntry it is associated with. I have no idea, why this worked before at all. Maybe some implicit tricks by sqlalchemy?
* | | Add index=True for some columns.Elrond2012-03-211-6/+7
| | | | | | | | | | | | | | | These are the columns that seem to make the most sense to have an index on them.
* | | Finally load all models.Elrond2012-03-211-2/+1
| | | | | | | | | | | | | | | Load all models for the media_types. This was stopped by a celery problem. But that is now fixed.
* | | Create load_models().Elrond2012-03-201-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So all models are ready when connecting to the db and so our "db" object has all models listed on it, create a function to load all models from the media_types, etc. Call it in setup_database() Problem: This gives celery warnings, because celery is imported before being setup properly. No idea how to fix this now. So media-type loading is excluded from load_models for now.
* | | Import "Base" from base instead of models.Elrond2012-03-202-4/+3
| | | | | | | | | | | | | | | Import the "Base" class for models from db.sql.base instead of db.sql.models.
* | | Disable query logging for now, so we get nicer logsElrond2012-03-201-1/+1
| |/ |/| | | | | | | | | As the queries are quite verbose, disable them for now. Reenabling them should be done in the central logging config, which is another story for celery and bin/gmg.
* | Let convert_mongo_to_sql add Migration RecordsElrond2012-03-171-1/+17
| | | | | | | | | | | | | | | | | | | | The mongosql tool is really dumping directly into the sql database and is trying not to use too much logic that might change later. So this means, it needs to create the migration records on its own! So add a bunch of records with version=0.
* | Make mediagoblin SQL models all use a consistent table naming schemeChristopher Allan Webber2012-03-171-11/+11
| |
* | Create function to search media by slug.Elrond2012-03-161-0/+9
| | | | | | | | | | | | | | | | | | 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.
* | Fix media display for no media_data row in sql.Elrond2012-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | If there is no media_data row for the current media (for whatever reason, there might be good ones), let MediaEntry.media_data not raise an exception but just return None. The exif display part now handles this by checking whether .media_data.exif is defined (None has no attribute exif, so it's undefined, all fine).
* | Implemented the MediaEntry .media_data type fields for SQLChristopher Allan Webber2012-03-141-4/+32
| |
* | Convert (gps) image media_data.Elrond2012-03-141-0/+23
| | | | | | | | | | | | Add mongo_to_sql convert part for converting the media_data for images. This currently drops the exif data and thus only converts gps data.
* | Fix VideoData insertionChristopher Allan Webber2012-03-141-1/+1
| |
* | Convert media_data for videoElrond2012-03-131-0/+15
|/ | | | | This creates fresh VideoData rows for all the videos in the mongodb.
* Improve logging of sql queries a bit.Elrond2012-03-101-1/+3
| | | | | | | | | | | | | | | | Docs: http://docs.sqlalchemy.org/en/latest/core/engines.html#configuring-logging So for an application utilizing python logging for real (and MediaGoblin should) the rule is: - Don't use echo=True, - but reconfigure the appropiate loggers' level. So replaced the echo=True by a line to reconfigure the appropiate logger to achieve the same effect. This still dumps whole bloats of SQL queries into the main log, but at least they're not duped any more.
* Forgot to add FileKeynames to MODELSElrond2012-03-081-1/+1
|
* Normalize MediaFile.name (make it a foreignkey)Elrond2012-03-081-3/+32
| | | | | | | | | | The name part of a MediaFile is only using a very limited number of items. Currently things like "original" or "thumb". So instead of storing the string on each entry, just store a short integer referencing the FileKeynames table and have the appropiate string there.
* SQL: Added MediaFile and MediaAttachmentFile to MODELSJoar Wandborg2012-03-081-1/+2
|
* Generic check_media_slug_used db utility.Elrond2012-03-051-1/+10
| | | | | | | | 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()
* SQL: Tool to cleanup unused tag slugs.Elrond2012-03-051-0/+22
| | | | | | | | 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!
* Implement atomic_update for SQL.Elrond2012-03-041-1/+14
| | | | | | On sqlalchemy most updates are atomic enough for most use cases. Anyway, here is an atomic_update that is compatible to the mongo version.
* And media_data_init() for sql as a dummyElrond2012-03-031-0/+4
| | | | Needs to be implemented.
* Create a fake MediaEntry.media_data for sqlElrond2012-03-031-0/+5
| | | | | | | So that the SQL backend is more useable, let the MediaEntry have a faked media_data. It's extremely fake: The returned dict is always a new one. So any stored info is even lost!
* SQL: Improve video media_data tableElrond2012-03-011-0/+1
| | | | | | 1. Make the foreignkey the primary_key. 2. Add width/height, as those are currently in use for the media_data
* Cleanup Session after each request.Elrond2012-02-281-0/+1
| | | | | | | | | | | It's good practice to cleanup the SQL session after each request so that the next request gets a fresh one. It's an application decision whether one wants a just-in-case ROLLBACK or COMMIT. There are two ideas behind it, really. I have decided for ROLLBACK. The idea is "if you forget to commit your changes yourself, there's something broken. Maybe you got an exception?".
* Attachment support in the SQL backendElrond2012-02-282-2/+36
| | | | | | | | | attachments working with the sql backend. - SQL Schema for attachment files, ordering attachments by their name, not by the submission order (as earlier). - Dot-Notation for attachments, where missing. - convert existing attachments over from mongo -> sql
* Let SQL objects support .setdefault() and .delete()Elrond2012-02-261-0/+10
| | | | | | | | | | Some parts in the code like to use .setdefault(). So make them happy and provide a minimal version. It ignores the given default and expects the attribute to already exist. Other parts use .delete() to delete a complete object. This version expects the object to live in a session and also does the final commit.
* Create "gmg convert_mongo_to_sql" commandElrond2012-02-231-3/+3
| | | | | | | | | Finally, to make testing of sql a bit easier, create a bin/gmg command to do the conversion from mongo to sql. It's currently named "convert_mongo_to_sql". The most important option is the gmg -cf option to give a configfile with the appropiate sql_engine definition.
* mongo to sql convert: Better OrderingElrond2012-02-231-4/+4
| | | | | | | | 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.
* Updates so that dbupdate command worksChristopher Allan Webber2012-02-181-1/+1
| | | | | | - Various fixes to dbupdate itself - Switching db/sql/migrations.py to use a dict instead of a list - Registering the function