mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 15:33:02 +00:00
update 0.8 alembic revision
add some missing transactions
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
"""encrypted_auth_state
|
||||
"""0.8 changes
|
||||
|
||||
- encrypted auth_state
|
||||
- remove proxy/hub data from db
|
||||
|
||||
OAuth data was also added in this revision,
|
||||
but no migration to do because they are entirely new tables,
|
||||
which will be created on launch.
|
||||
|
||||
Revision ID: 3ec6993fe20c
|
||||
Revises: af4cbdb2d13c
|
||||
@@ -12,7 +19,9 @@ down_revision = 'af4cbdb2d13c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
import warnings
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger('alembic')
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@@ -20,15 +29,36 @@ from jupyterhub.orm import JSONDict
|
||||
|
||||
|
||||
def upgrade():
|
||||
# proxy/table info is no longer in the database
|
||||
op.drop_table('proxies')
|
||||
op.drop_table('hubs')
|
||||
|
||||
# drop some columns no longer in use
|
||||
try:
|
||||
op.drop_column('users', 'auth_state')
|
||||
except sa.exc.OperationalError as e:
|
||||
# sqlite3 can't drop columns
|
||||
warnings.warn("Failed to drop column: %s" % e)
|
||||
op.drop_column('users', '_server_id')
|
||||
except sa.exc.OperationalError:
|
||||
# this won't be a problem moving forward, but downgrade will fail
|
||||
if op.get_context().dialect.name == 'sqlite':
|
||||
logger.warning("sqlite cannot drop columns. Leaving unused old columns in place.")
|
||||
else:
|
||||
raise
|
||||
|
||||
op.add_column('users', sa.Column('encrypted_auth_state', sa.types.LargeBinary))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('users', 'encrypted_auth_state')
|
||||
op.add_column('users', sa.Column('auth_state', JSONDict))
|
||||
# drop all the new tables
|
||||
engine = op.get_bind().engine
|
||||
for table in ('oauth_clients',
|
||||
'oauth_codes',
|
||||
'oauth_access_tokens',
|
||||
'spawners'):
|
||||
if engine.has_table(table):
|
||||
op.drop_table(table)
|
||||
|
||||
op.drop_column('users', 'encrypted_auth_state')
|
||||
|
||||
op.add_column('users', sa.Column('auth_state', JSONDict))
|
||||
op.add_column('users', sa.Column('_server_id', sa.Integer, sa.ForeignKey('servers.id')))
|
||||
|
||||
|
Reference in New Issue
Block a user