mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Add check constraint to validate texture pack licenses
This commit is contained in:
parent
a2a38f1e14
commit
1fc4852e77
@ -393,6 +393,8 @@ class Package(db.Model):
|
|||||||
media_license_id = db.Column(db.Integer, db.ForeignKey("license.id"), nullable=False, default=1)
|
media_license_id = db.Column(db.Integer, db.ForeignKey("license.id"), nullable=False, default=1)
|
||||||
media_license = db.relationship("License", foreign_keys=[media_license_id])
|
media_license = db.relationship("License", foreign_keys=[media_license_id])
|
||||||
|
|
||||||
|
ck_license_txp = db.CheckConstraint("type != 'TXP' OR license_id = media_license_id")
|
||||||
|
|
||||||
state = db.Column(db.Enum(PackageState), nullable=False, default=PackageState.WIP)
|
state = db.Column(db.Enum(PackageState), nullable=False, default=PackageState.WIP)
|
||||||
dev_state = db.Column(db.Enum(PackageDevState), nullable=True, default=None)
|
dev_state = db.Column(db.Enum(PackageDevState), nullable=True, default=None)
|
||||||
|
|
||||||
|
23
migrations/versions/23afcf580aae_.py
Normal file
23
migrations/versions/23afcf580aae_.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 23afcf580aae
|
||||||
|
Revises: dabd7ab14339
|
||||||
|
Create Date: 2023-05-11 22:02:24.021652
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '23afcf580aae'
|
||||||
|
down_revision = 'dabd7ab14339'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_check_constraint("ck_license_txp", "package", "type != 'TXP' OR license_id = media_license_id")
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_constraint("ck_license_txp", "package", type_="check")
|
Loading…
Reference in New Issue
Block a user