Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add id_import in monitoring model #3275

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
)
Loading