API - remove 'img' column from sport since it's not used anymore
This commit is contained in:
		@@ -17,6 +17,10 @@ depends_on = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def upgrade():
 | 
			
		||||
 | 
			
		||||
    op.drop_constraint('sports_img_key', 'sports', type_='unique')
 | 
			
		||||
    op.drop_column('sports', 'img')
 | 
			
		||||
 | 
			
		||||
    op.create_table(
 | 
			
		||||
        'users_sports_preferences',
 | 
			
		||||
        sa.Column('user_id', sa.Integer(), nullable=False),
 | 
			
		||||
@@ -41,6 +45,32 @@ def upgrade():
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def downgrade():
 | 
			
		||||
    # ### commands auto generated by Alembic - please adjust! ###
 | 
			
		||||
    op.drop_table('users_sports_preferences')
 | 
			
		||||
    # ### end Alembic commands ###
 | 
			
		||||
 | 
			
		||||
    op.add_column(
 | 
			
		||||
        'sports',
 | 
			
		||||
        sa.Column(
 | 
			
		||||
            'img', sa.VARCHAR(length=255), autoincrement=False, nullable=True
 | 
			
		||||
        ),
 | 
			
		||||
    )
 | 
			
		||||
    op.create_unique_constraint('sports_img_key', 'sports', ['img'])
 | 
			
		||||
    op.execute(
 | 
			
		||||
        """
 | 
			
		||||
        UPDATE sports AS s
 | 
			
		||||
        SET img = si.img
 | 
			
		||||
        FROM (VALUES
 | 
			
		||||
            ('Cycling (Sport)','/img/sports/cycling-sport.png'),
 | 
			
		||||
            ('Cycling (Transport)','/img/sports/cycling-transport.png'),
 | 
			
		||||
            ('Hiking','/img/sports/hiking.png'),
 | 
			
		||||
            ('Mountain Biking','/img/sports/mountain-biking.png'),
 | 
			
		||||
            ('Running','/img/sports/running.png'),
 | 
			
		||||
            ('Walking','/img/sports/walking.png'),
 | 
			
		||||
            ('Mountain Biking (Electric)','/img/sports/electric-mountain-biking.png'),
 | 
			
		||||
            ('Trail','/img/sports/trail.png'),
 | 
			
		||||
            ('Skiing (Alpine)','/img/sports/alpine-skiing.png'),
 | 
			
		||||
            ('Skiing (Cross Country)','/img/sports/cross-country-skiing.png'),
 | 
			
		||||
            ('Rowing','/img/sports/rowing.png')
 | 
			
		||||
        ) AS si(label, img)
 | 
			
		||||
        WHERE si.label = s.label;
 | 
			
		||||
        """
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user