Skip to content

Commit

Permalink
feat(monitoring, db): add id_import column for each entity in monitor…
Browse files Browse the repository at this point in the history
…ing model (#3275)

* add id_import in monitoring model
* feat: add id_import columns in monitoring tables
* fix(db): change head of revision to latest in feat/import-monitorings

---------

Co-authored-by: Julien Corny <[email protected]>
Co-authored-by: jacquesfize <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent 38aea2f commit 2b5f26f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/geonature/core/gn_monitoring/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class TBaseVisits(DB.Model):
foreign_keys=[id_dataset],
)

id_import = DB.Column(DB.Integer, nullable=True)


@serializable
@geoserializable(geoCol="geom", idCol="id_base_site")
Expand Down Expand Up @@ -212,6 +214,8 @@ class TBaseSites(DB.Model):
foreign_keys=[cor_site_module.c.id_base_site, cor_site_module.c.id_module],
)

id_import = DB.Column(DB.Integer, nullable=True)


@serializable
class TObservations(DB.Model):
Expand All @@ -226,3 +230,4 @@ class TObservations(DB.Model):
cd_nom = DB.Column(DB.Integer)
comments = DB.Column(DB.String)
uuid_observation = DB.Column(UUID(as_uuid=True), default=select(func.uuid_generate_v4()))
id_import = DB.Column(DB.Integer, nullable=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""[monitoring] add id_import column for each entity
Revision ID: df277299fdda
Revises: 6734d8f7eb2a
Create Date: 2024-11-28 18:20:49.512808
"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "df277299fdda"
down_revision = "a94bea44ab56"
branch_labels = None
depends_on = None

import_column_name = "id_import"
schema = "gn_monitoring"
entity_tables = ["t_base_sites", "t_base_visits", "t_observations"]


def upgrade():
for table in entity_tables:
op.add_column(
schema=schema,
table_name=table,
column=sa.Column(import_column_name, sa.Integer, nullable=True),
)


def downgrade():
for table in entity_tables:
op.drop_column(
schema=schema,
table_name=table,
column_name=import_column_name,
)

0 comments on commit 2b5f26f

Please sign in to comment.