1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
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.
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.
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/>.
17 from sqlalchemy
import MetaData
, Table
, Column
, Boolean
, SmallInteger
19 from mediagoblin
.db
.sql
.util
import RegisterMigration
25 @RegisterMigration(1, MIGRATIONS
)
26 def ogg_to_webm_audio(db_conn
):
27 metadata
= MetaData(bind
=db_conn
.bind
)
29 file_keynames
= Table('core__file_keynames', metadata
, autoload
=True,
30 autoload_with
=db_conn
.bind
)
33 file_keynames
.update().where(file_keynames
.c
.name
== 'ogg').
34 values(name
='webm_audio')
39 @RegisterMigration(2, MIGRATIONS
)
40 def add_wants_notification_column(db_conn
):
41 metadata
= MetaData(bind
=db_conn
.bind
)
43 users
= Table('core__users', metadata
, autoload
=True,
44 autoload_with
=db_conn
.bind
)
46 col
= Column('wants_comment_notification', Boolean
,
47 default
=True, nullable
=True)
48 col
.create(users
, populate_defaults
=True)
52 @RegisterMigration(3, MIGRATIONS
)
53 def add_transcoding_progress(db_conn
):
54 metadata
= MetaData(bind
=db_conn
.bind
)
56 media_entry
= Table('core__media_entries', metadata
, autoload
=True,
57 autoload_with
=db_conn
.bind
)
59 col
= Column('transcoding_progress', SmallInteger
)
60 col
.create(media_entry
)