Skip to content

Commit

Permalink
🏗️ Naming conventions for link tables, protecting deletion in link ta…
Browse files Browse the repository at this point in the history
…bles, maintaining integrity upon label & feature renames (#383)

* ♻️ Also indicate whether semantic identifiers were used

* 💚 Fix

* 🍱 Add squashed version
  • Loading branch information
falexwolf authored May 18, 2024
1 parent 9ccd6b4 commit f087c5a
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Migration(migrations.Migration):
migrations.RunSQL(
"""
-- Replace all occurrences of "core." in dtype with an empty string
UPDATE your_app_name_feature
UPDATE lnschema_core_feature
SET dtype = REPLACE(dtype, 'core.', '');
"""
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Generated by Django 5.0.6 on 2024-05-18 13:44

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("lnschema_core", "0049_rename_type_feature_dtype_and_more"),
]

operations = [
migrations.AddField(
model_name="artifactfeatureset",
name="feature_ref_is_semantic",
field=models.BooleanField(default=None, null=True),
),
migrations.AddField(
model_name="artifactulabel",
name="feature_ref_is_name",
field=models.BooleanField(default=None, null=True),
),
migrations.AddField(
model_name="artifactulabel",
name="ulabel_ref_is_name",
field=models.BooleanField(default=None, null=True),
),
migrations.AddField(
model_name="collectionfeatureset",
name="feature_ref_is_semantic",
field=models.BooleanField(default=None, null=True),
),
migrations.AddField(
model_name="collectionulabel",
name="feature_ref_is_name",
field=models.BooleanField(default=None, null=True),
),
migrations.AddField(
model_name="collectionulabel",
name="ulabel_ref_is_name",
field=models.BooleanField(default=None, null=True),
),
migrations.AlterField(
model_name="artifactfeatureset",
name="artifact",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="feature_set_links",
to="lnschema_core.artifact",
),
),
migrations.AlterField(
model_name="artifactfeatureset",
name="feature_set",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="artifact_links",
to="lnschema_core.featureset",
),
),
migrations.AlterField(
model_name="artifactfeaturevalue",
name="artifact",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="lnschema_core.artifact",
),
),
migrations.AlterField(
model_name="artifactfeaturevalue",
name="feature_value",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.featurevalue",
),
),
migrations.AlterField(
model_name="artifactulabel",
name="artifact",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="ulabel_links",
to="lnschema_core.artifact",
),
),
migrations.AlterField(
model_name="artifactulabel",
name="feature",
field=models.ForeignKey(
default=None,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="artifactulabel_links",
to="lnschema_core.feature",
),
),
migrations.AlterField(
model_name="artifactulabel",
name="ulabel",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="artifact_links",
to="lnschema_core.ulabel",
),
),
migrations.AlterField(
model_name="collectionartifact",
name="artifact",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.artifact",
),
),
migrations.AlterField(
model_name="collectionartifact",
name="collection",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="lnschema_core.collection",
),
),
migrations.AlterField(
model_name="collectionfeatureset",
name="collection",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="feature_set_links",
to="lnschema_core.collection",
),
),
migrations.AlterField(
model_name="collectionfeatureset",
name="feature_set",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="collection_links",
to="lnschema_core.featureset",
),
),
migrations.AlterField(
model_name="collectionulabel",
name="collection",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="ulabel_links",
to="lnschema_core.collection",
),
),
migrations.AlterField(
model_name="collectionulabel",
name="feature",
field=models.ForeignKey(
default=None,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="collectionulabel_links",
to="lnschema_core.feature",
),
),
migrations.AlterField(
model_name="collectionulabel",
name="ulabel",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="collection_links",
to="lnschema_core.ulabel",
),
),
migrations.AlterField(
model_name="runparamvalue",
name="param_value",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.paramvalue",
),
),
migrations.AlterField(
model_name="runparamvalue",
name="run",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="lnschema_core.run",
),
),
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.0.6 on 2024-05-17 20:40
# Generated by Django 5.0.6 on 2024-05-18 13:50

import django.db.models.deletion
from django.db import migrations, models
Expand Down Expand Up @@ -39,6 +39,7 @@ class Migration(migrations.Migration):
("lnschema_core", "0047_featurevalue_artifactfeaturevalue_and_more"),
("lnschema_core", "0048_alter_artifactulabel_feature_and_more"),
("lnschema_core", "0049_rename_type_feature_dtype_and_more"),
("lnschema_core", "0050_artifactfeatureset_feature_ref_is_semantic_and_more"),
]

dependencies = [] # type: ignore
Expand Down Expand Up @@ -308,14 +309,16 @@ class Migration(migrations.Migration):
(
"artifact",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.artifact",
),
),
(
"collection",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="lnschema_core.collection",
),
),
Expand Down Expand Up @@ -388,17 +391,23 @@ class Migration(migrations.Migration):
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("slot", models.CharField(default=None, max_length=50, null=True)),
(
"feature_ref_is_semantic",
models.BooleanField(default=None, null=True),
),
(
"collection",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="feature_set_links",
to="lnschema_core.collection",
),
),
(
"feature_set",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
on_delete=django.db.models.deletion.PROTECT,
related_name="collection_links",
to="lnschema_core.featureset",
),
),
Expand All @@ -422,17 +431,23 @@ class Migration(migrations.Migration):
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("slot", models.CharField(default=None, max_length=40, null=True)),
(
"feature_ref_is_semantic",
models.BooleanField(default=None, null=True),
),
(
"artifact",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="feature_set_links",
to="lnschema_core.artifact",
),
),
(
"feature_set",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
on_delete=django.db.models.deletion.PROTECT,
related_name="artifact_links",
to="lnschema_core.featureset",
),
),
Expand Down Expand Up @@ -496,13 +511,15 @@ class Migration(migrations.Migration):
"artifact",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="lnschema_core.artifact",
),
),
(
"feature_value",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.featurevalue",
),
),
Expand Down Expand Up @@ -666,14 +683,16 @@ class Migration(migrations.Migration):
(
"param_value",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="lnschema_core.paramvalue",
),
),
(
"run",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="lnschema_core.run",
),
),
Expand Down Expand Up @@ -895,10 +914,13 @@ class Migration(migrations.Migration):
name="CollectionULabel",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("ulabel_ref_is_name", models.BooleanField(default=None, null=True)),
("feature_ref_is_name", models.BooleanField(default=None, null=True)),
(
"collection",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="ulabel_links",
to="lnschema_core.collection",
),
),
Expand All @@ -908,13 +930,15 @@ class Migration(migrations.Migration):
default=None,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="collectionulabel_links",
to="lnschema_core.feature",
),
),
(
"ulabel",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
on_delete=django.db.models.deletion.PROTECT,
related_name="collection_links",
to="lnschema_core.ulabel",
),
),
Expand All @@ -937,10 +961,13 @@ class Migration(migrations.Migration):
name="ArtifactULabel",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("ulabel_ref_is_name", models.BooleanField(default=None, null=True)),
("feature_ref_is_name", models.BooleanField(default=None, null=True)),
(
"artifact",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="ulabel_links",
to="lnschema_core.artifact",
),
),
Expand All @@ -950,13 +977,15 @@ class Migration(migrations.Migration):
default=None,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="artifactulabel_links",
to="lnschema_core.feature",
),
),
(
"ulabel",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
on_delete=django.db.models.deletion.PROTECT,
related_name="artifact_links",
to="lnschema_core.ulabel",
),
),
Expand Down
Loading

0 comments on commit f087c5a

Please sign in to comment.