Fixed validation in API post_entry.
[mediagoblin.git] / mediagoblin / db / sql / migrations.py
1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 from sqlalchemy import MetaData, Table, Column, Boolean, SmallInteger
18
19 from mediagoblin.db.sql.util import RegisterMigration
20
21
22 MIGRATIONS = {}
23
24
25 @RegisterMigration(1, MIGRATIONS)
26 def ogg_to_webm_audio(db_conn):
27 metadata = MetaData(bind=db_conn.bind)
28
29 file_keynames = Table('core__file_keynames', metadata, autoload=True,
30 autoload_with=db_conn.bind)
31
32 db_conn.execute(
33 file_keynames.update().where(file_keynames.c.name == 'ogg').
34 values(name='webm_audio')
35 )
36 db_conn.commit()
37
38
39 @RegisterMigration(2, MIGRATIONS)
40 def add_wants_notification_column(db_conn):
41 metadata = MetaData(bind=db_conn.bind)
42
43 users = Table('core__users', metadata, autoload=True,
44 autoload_with=db_conn.bind)
45
46 col = Column('wants_comment_notification', Boolean,
47 default=True, nullable=True)
48 col.create(users, populate_defaults=True)
49 db_conn.commit()
50
51
52 @RegisterMigration(3, MIGRATIONS)
53 def add_transcoding_progress(db_conn):
54 metadata = MetaData(bind=db_conn.bind)
55
56 media_entry = Table('core__media_entries', metadata, autoload=True,
57 autoload_with=db_conn.bind)
58
59 col = Column('transcoding_progress', SmallInteger)
60 col.create(media_entry)
61 db_conn.commit()