-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13240be
commit 1056a54
Showing
5 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
api/desecapi/migrations/0040_token_auto_policy_token_token_auto_policy_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Generated by Django 5.1.3 on 2024-11-20 16:08 | ||
|
||
import pgtrigger.compiler | ||
import pgtrigger.migrations | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("desecapi", "0039_token_perm_create_domain_token_perm_delete_domain"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="token", | ||
name="auto_policy", | ||
field=models.BooleanField(default=False), | ||
), | ||
pgtrigger.migrations.AddTrigger( | ||
model_name="token", | ||
trigger=pgtrigger.compiler.Trigger( | ||
name="token_auto_policy", | ||
sql=pgtrigger.compiler.UpsertTriggerSql( | ||
constraint="CONSTRAINT", | ||
func="\n IF\n NEW.auto_policy = true AND NOT EXISTS(\n SELECT * FROM desecapi_tokendomainpolicy WHERE token_id = NEW.id AND domain_id IS NULL AND subname IS NULL AND type IS NULL\n )\n THEN\n RAISE EXCEPTION 'Token auto policy without a default policy is not allowed.';\n END IF;\n RETURN NULL;\n ", | ||
hash="890632f787e37adaed486fb702cc9f929449f04c", | ||
operation="UPDATE OR INSERT", | ||
pgid="pgtrigger_token_auto_policy_8e6d9", | ||
table="desecapi_token", | ||
timing="DEFERRABLE INITIALLY DEFERRED", | ||
when="AFTER", | ||
), | ||
), | ||
), | ||
pgtrigger.migrations.AddTrigger( | ||
model_name="tokendomainpolicy", | ||
trigger=pgtrigger.compiler.Trigger( | ||
name="default_policy_when_auto_policy", | ||
sql=pgtrigger.compiler.UpsertTriggerSql( | ||
func="\n IF\n OLD.domain_id IS NULL AND OLD.subname IS NULL AND OLD.type IS NULL AND (SELECT auto_policy FROM desecapi_token WHERE id = OLD.token_id) = true\n THEN\n RAISE EXCEPTION 'Cannot delete default policy while auto_policy is in effect.';\n END IF;\n RETURN OLD;\n ", | ||
hash="08b8e7ab285d9e5a6bd612ff0704aeaa328438d2", | ||
operation="DELETE", | ||
pgid="pgtrigger_default_policy_when_auto_policy_a1fd2", | ||
table="desecapi_tokendomainpolicy", | ||
when="BEFORE", | ||
), | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters