aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/plugins/oauth/migrations.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-04-13 20:21:14 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-04-13 20:21:14 -0500
commit0f6ab7da86c67557233a4785d52c81bcc6da79f3 (patch)
tree924d0f9776d78889e0b36a262f06cf08da373a2b /mediagoblin/plugins/oauth/migrations.py
parentf4f9d7ca95a7a00096622961c00d3c941ee846b7 (diff)
parent64598a79a9648416e9cc49349e57190792cc59f2 (diff)
downloadmediagoblin-0f6ab7da86c67557233a4785d52c81bcc6da79f3.tar.lz
mediagoblin-0f6ab7da86c67557233a4785d52c81bcc6da79f3.tar.xz
mediagoblin-0f6ab7da86c67557233a4785d52c81bcc6da79f3.zip
Merge branch 'master' of gitorious.org:mediagoblin/mediagoblin
Diffstat (limited to 'mediagoblin/plugins/oauth/migrations.py')
-rw-r--r--mediagoblin/plugins/oauth/migrations.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/mediagoblin/plugins/oauth/migrations.py b/mediagoblin/plugins/oauth/migrations.py
index 6aa0d7cb..d7b89da3 100644
--- a/mediagoblin/plugins/oauth/migrations.py
+++ b/mediagoblin/plugins/oauth/migrations.py
@@ -102,6 +102,21 @@ class OAuthCode_v0(declarative_base()):
client_id = Column(Integer, ForeignKey(OAuthClient_v0.id), nullable=False)
+class OAuthRefreshToken_v0(declarative_base()):
+ __tablename__ = 'oauth__refresh_tokens'
+
+ id = Column(Integer, primary_key=True)
+ created = Column(DateTime, nullable=False,
+ default=datetime.now)
+
+ token = Column(Unicode, index=True)
+
+ user_id = Column(Integer, ForeignKey(User.id), nullable=False)
+
+ # XXX: Is it OK to use OAuthClient_v0.id in this way?
+ client_id = Column(Integer, ForeignKey(OAuthClient_v0.id), nullable=False)
+
+
@RegisterMigration(1, MIGRATIONS)
def remove_and_replace_token_and_code(db):
metadata = MetaData(bind=db.bind)
@@ -122,3 +137,22 @@ def remove_and_replace_token_and_code(db):
OAuthCode_v0.__table__.create(db.bind)
db.commit()
+
+
+@RegisterMigration(2, MIGRATIONS)
+def remove_refresh_token_field(db):
+ metadata = MetaData(bind=db.bind)
+
+ token_table = Table('oauth__tokens', metadata, autoload=True,
+ autoload_with=db.bind)
+
+ refresh_token = token_table.columns['refresh_token']
+
+ refresh_token.drop()
+ db.commit()
+
+@RegisterMigration(3, MIGRATIONS)
+def create_refresh_token_table(db):
+ OAuthRefreshToken_v0.__table__.create(db.bind)
+
+ db.commit()