OpenID plugin initial migration.
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 12 Mar 2016 23:36:41 +0000 (15:36 -0800)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 26 Mar 2016 18:39:07 +0000 (11:39 -0700)
* mediagoblin/plugins/openid/migrations/071abb33d1da_openid_plugin_initial_migration.py:
  New file.

mediagoblin/plugins/openid/migrations/071abb33d1da_openid_plugin_initial_migration.py [new file with mode: 0644]

diff --git a/mediagoblin/plugins/openid/migrations/071abb33d1da_openid_plugin_initial_migration.py b/mediagoblin/plugins/openid/migrations/071abb33d1da_openid_plugin_initial_migration.py
new file mode 100644 (file)
index 0000000..b6b97da
--- /dev/null
@@ -0,0 +1,54 @@
+"""OpenID plugin initial migration
+
+Revision ID: 071abb33d1da
+Revises: 52bf0ccbedc1
+Create Date: 2016-03-12 23:32:58.191980
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '071abb33d1da'
+down_revision = '52bf0ccbedc1'
+branch_labels = ('openid_plugin',)
+depends_on = None
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+    if op.get_bind().engine.has_table('openid__association'):
+        # Skip; this has already been instantiated
+        # (probably via sqlalchemy-migrate)
+        return
+
+    op.create_table(
+        'openid__association',
+        sa.Column('server_url', sa.Unicode(), nullable=False),
+        sa.Column('handle', sa.Unicode(), nullable=False),
+        sa.Column('secret', sa.Unicode(), nullable=True),
+        sa.Column('issued', sa.Integer(), nullable=True),
+        sa.Column('lifetime', sa.Integer(), nullable=True),
+        sa.Column('assoc_type', sa.Unicode(), nullable=True),
+        sa.PrimaryKeyConstraint('server_url', 'handle'))
+
+    op.create_table(
+        'openid__nonce',
+        sa.Column('server_url', sa.Unicode(), nullable=False),
+        sa.Column('timestamp', sa.Integer(), nullable=False),
+        sa.Column('salt', sa.Unicode(), nullable=False),
+        sa.PrimaryKeyConstraint('server_url', 'timestamp', 'salt'))
+
+    op.create_table(
+        'openid__user_urls',
+        sa.Column('id', sa.Integer(), nullable=False),
+        sa.Column('openid_url', sa.Unicode(), nullable=False),
+        sa.Column('user_id', sa.Integer(), nullable=False),
+        sa.ForeignKeyConstraint(['user_id'], ['core__users.id'], ),
+        sa.PrimaryKeyConstraint('id'))
+
+
+def downgrade():
+    op.drop_table('openid__user_urls')
+    op.drop_table('openid__nonce')
+    op.drop_table('openid__association')