This commit is contained in:
Kateřina Churanová 2022-01-02 15:35:02 +01:00 committed by GitHub
commit 7bdf71b613
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -0,0 +1,24 @@
"""Add unique index to settings table keys
Revision ID: b24bf17725d2
Revises: 0967658d9c0d
Create Date: 2021-12-12 20:29:17.103441
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b24bf17725d2'
down_revision = '0967658d9c0d'
branch_labels = None
depends_on = None
def upgrade():
op.create_index(op.f('ix_setting_name'), 'setting', ['name'], unique=True)
def downgrade():
op.drop_index(op.f('ix_setting_name'), table_name='setting')

View file

@ -11,7 +11,7 @@ from .base import db
class Setting(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64))
name = db.Column(db.String(64), unique=True, index=True)
value = db.Column(db.Text())
defaults = {