Skip to content

Commit

Permalink
Merge pull request #1573 from betagouv/fix-missing-id
Browse files Browse the repository at this point in the history
🐞 Fix ProgrammingError à cause du champ id manquant dans les modèles Ica_ sans primary_key
  • Loading branch information
pletelli authored Feb 3, 2025
2 parents bfacf52 + 0fe6696 commit 267dd33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions data/models/teleicare_history/ica_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ class Meta:


class IcaPopulationCibleDeclaree(models.Model):
vrsdecl_ident = models.IntegerField()
vrsdecl_ident = models.IntegerField(
primary_key=True
) # ce champ n'est en réalité pas une primary key, car la primary key est composite.
# Django ne permet pas de créer des clés composites et nécessite la création d'un champ id, si ce champ n'est pas spécifié comme primary_key
# Comme le modèle est unmanaged, cette contrainte ne change rien en BDD
popcbl_ident = models.IntegerField()
vrspcb_popcible_autre = models.TextField(blank=True, null=True)

Expand All @@ -111,7 +115,7 @@ class Meta:


class IcaPopulationRisqueDeclaree(models.Model):
vrsdecl_ident = models.IntegerField()
vrsdecl_ident = models.IntegerField(primary_key=True) # idem IcaPopulationCibleDeclaree
poprs_ident = models.IntegerField()
vrsprs_poprisque_autre = models.TextField(blank=True, null=True)

Expand All @@ -122,7 +126,7 @@ class Meta:


class IcaEffetDeclare(models.Model):
vrsdecl_ident = models.IntegerField()
vrsdecl_ident = models.IntegerField(primary_key=True) # idem IcaPopulationCibleDeclaree
objeff_ident = models.IntegerField()
vrs_autre_objectif = models.TextField(blank=True, null=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Meta:


class IcaSubstanceDeclaree(models.Model):
vrsdecl_ident = models.IntegerField()
vrsdecl_ident = models.IntegerField(primary_key=True) # idem IcaPopulationCibleDeclaree
sbsact_ident = models.IntegerField()
sbsact_commentaires = models.TextField(blank=True, null=True)
sbsactdecl_quantite_par_djr = models.FloatField(blank=True, null=True)
Expand Down

0 comments on commit 267dd33

Please sign in to comment.