Les codes de département peuvent avoir 3 caractères

This commit is contained in:
Emmy D'Anello 2024-06-09 16:47:37 +02:00
parent eed4dc18fb
commit d6ed4eed17
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 3 additions and 3 deletions

View File

@ -52,7 +52,7 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint('id')
)
op.create_table('departement',
sa.Column('code_insee', sa.String(length=2), nullable=False),
sa.Column('code_insee', sa.String(length=3), nullable=False),
sa.Column('libelle', sa.String(length=64), nullable=False),
sa.Column('region_code', sa.String(length=3), nullable=False),
sa.Column('geometry', sa.JSON(), nullable=False),
@ -112,7 +112,7 @@ def upgrade() -> None:
op.create_table('commune',
sa.Column('code_insee', sa.String(length=5), nullable=False),
sa.Column('libelle', sa.String(length=64), nullable=False),
sa.Column('departement_code', sa.String(length=2), nullable=False),
sa.Column('departement_code', sa.String(length=3), nullable=False),
sa.Column('geometry', sa.JSON(), nullable=False),
sa.ForeignKeyConstraint(['departement_code'], ['departement.code_insee'], ),
sa.PrimaryKeyConstraint('code_insee')

View File

@ -21,7 +21,7 @@ class Region(Base):
class Departement(Base):
__tablename__ = "departement"
code_insee: Mapped[str] = mapped_column(String(2), primary_key=True)
code_insee: Mapped[str] = mapped_column(String(3), primary_key=True)
libelle: Mapped[str] = mapped_column(String(64), unique=True)
region_code: Mapped[int] = mapped_column(ForeignKey("region.code_insee"))
geometry: Mapped[dict] = mapped_column(JSON())