Add constraint for release tasks and approval

This commit is contained in:
rubenwardy 2020-01-18 23:10:11 +00:00
parent 5a496f6858
commit 22d02edbd8
3 changed files with 31 additions and 0 deletions

@ -732,6 +732,8 @@ class PackageRelease(db.Model):
max_rel_id = db.Column(db.Integer, db.ForeignKey("minetest_release.id"), nullable=True, server_default=None)
max_rel = db.relationship("MinetestRelease", foreign_keys=[max_rel_id])
# If the release is approved, then the task_id must be null and the url must be present
CK_approval_valid = db.CheckConstraint("not approved OR (task_id IS NULL AND (url = '') IS NOT FALSE)")
def getEditURL(self):
return url_for("packages.edit_release",

@ -0,0 +1,26 @@
"""empty message
Revision ID: 306ce331a2a7
Revises: 6dca6eceb04d
Create Date: 2020-01-18 23:00:40.487425
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '306ce331a2a7'
down_revision = '6dca6eceb04d'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
op.create_check_constraint("CK_approval_valid", "package_release", "not approved OR (task_id IS NULL AND NOT url = '')")
def downgrade():
conn = op.get_bind()
op.drop_constraint("CK_approval_valid", "package_release", type_="check")

3
utils/bash.sh Executable file

@ -0,0 +1,3 @@
#!/bin/bash
docker exec -it contentdb_app_1 bash