fix: making the key name in the config database unique

This commit is contained in:
Kateřina Churanová 2021-12-11 15:49:05 +01:00
parent 0da9b2185e
commit eb70f6a066
No known key found for this signature in database
GPG Key ID: CEDA54FB0EE5791E
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 = {