|
2 | 2 |
|
3 | 3 | """ Special Deletion Rules for table relationships
|
4 | 4 |
|
5 |
| - Of the form: base_table : { field_name: action} |
| 5 | + Of the form: 'relatedTable.relName' : action, |
| 6 | + where relName is the field name of the relationship in relatedTable |
| 7 | +
|
| 8 | + For example, 'Accessionagent.accession' : models.CASCADE |
| 9 | + would delete the associated Accession Agent when Accession is deleted |
| 10 | + |
| 11 | + The field and relationship names can be viewed at |
| 12 | + https://files.specifysoftware.org/schema/version/2.10/ |
6 | 13 |
|
7 | 14 | Possible Django actions (w/ django 2.2) are:
|
8 | 15 | CASCADE, PROTECT, SET_NULL, SET_DEFAULT, SET(...), DO_NOTHING
|
|
13 | 20 | See .build_models.py for uses
|
14 | 21 | """
|
15 | 22 | SPECIAL_DELETION_RULES = {
|
16 |
| - 'Spappresource' : {'spreport': models.CASCADE}, |
17 |
| - |
18 |
| - 'Recordset' : {'recordsetitem' : models.CASCADE}, |
19 |
| - |
20 |
| - 'Specifyuser' : { |
21 |
| - 'agent' : models.SET_NULL, |
22 |
| - 'spAppResourceDir' : models.CASCADE, |
23 |
| - 'spAppResource': models.CASCADE, |
24 |
| - 'spPrincipal': models.CASCADE, |
25 |
| - }, |
26 |
| - |
27 |
| - # Handle workbench deletion using raw sql in business rules. |
28 |
| - 'Workbench' : {'workbenchrow': models.DO_NOTHING}, |
29 |
| - 'Workbenchrow' : { |
30 |
| - 'workbenchdataitem' : models.DO_NOTHING, |
31 |
| - 'workbenchrowimage' : models.DO_NOTHING, |
32 |
| - 'workbenchrowexportedrelationship' : models.DO_NOTHING, |
33 |
| - }, |
34 |
| - |
35 |
| - # System Tables |
36 |
| - |
37 |
| - 'Spauditlog' : {'field' : models.CASCADE}, |
38 |
| - |
39 |
| - 'Spappresource' : {'spAppResourceData': models.CASCADE}, |
40 |
| - 'Spappresourcedir' : { |
41 |
| - 'spPersistedAppResource': models.CASCADE, |
42 |
| - 'spPersistedViewSet' : models.CASCADE, |
43 |
| - }, |
44 |
| - 'Spviewsetobj' : {'spAppResourceData' : models.CASCADE}, |
45 |
| - |
46 |
| - 'Splocalecontainer' : { |
47 |
| - 'item' : models.CASCADE, |
48 |
| - 'name' : models.CASCADE |
49 |
| - }, |
50 |
| - 'Splocalecontaineritem' : { |
51 |
| - 'name' : models.CASCADE |
52 |
| - }, |
53 |
| - 'SpQuery' : {"field" : models.CASCADE}, |
| 23 | + 'Agent.specifyuser' : models.SET_NULL, |
| 24 | + |
| 25 | + # Handle workbench deletion using raw sql in business rules. |
| 26 | + 'Workbenchrow.workbench': models.DO_NOTHING, |
| 27 | + 'Workbenchdataitem.workbenchrow': models.DO_NOTHING, |
| 28 | + 'Workbenchrowimage.workbenchrow': models.DO_NOTHING, |
| 29 | + 'Workbenchrowexportedrelationship.workbenchrow': models.DO_NOTHING, |
| 30 | + |
| 31 | + # These fields are not marked as dependent because the relationship |
| 32 | + # can be null |
| 33 | + 'Spappresourcedir.specifyuser': models.CASCADE, |
| 34 | + 'Spappresource.specifyuser': models.CASCADE, |
| 35 | + 'Spappresourcedata.spappresource': models.CASCADE, |
| 36 | + 'Spappresourcedata.spviewsetobj': models.CASCADE, |
| 37 | + |
| 38 | + # In addition to these rules, Specify Cascades relationships tagged as dependent |
| 39 | + # For the complete list, see the global variable called |
| 40 | + # dependent_fields in .load_datamodel.py |
| 41 | + |
| 42 | + # If the field/relationship is not dependent and not defined here, then it is |
| 43 | + # protected |
54 | 44 | }
|
55 | 45 |
|
56 | 46 | """ Any additional desired delete blockers
|
57 | 47 | Of the form 'base_table': ['field_1_name', 'field_2_name', ...]
|
58 |
| -Use the django attributes from the 'base_table' for field names |
59 | 48 |
|
60 | 49 | See .build_models.py and .views.py for uses
|
61 | 50 | """
|
|
0 commit comments