from flask import current_app
from geoalchemy2 import Geometry

from utils_flask_sqla.serializers import serializable
from utils_flask_sqla_geo.serializers import geoserializable

from geonature.utils.env import DB

@serializable
class VmCorTaxonPhenology(DB.Model):
    __tablename__ = "vm_cor_taxon_phenology"
    __table_args__ = {"schema": "gn_profiles"}
    cd_ref = DB.Column(DB.Integer)
    period = DB.Column(DB.Integer)
    id_nomenclature_life_stage = DB.Column(DB.Integer)
    id_altitude_range = DB.Column(DB.Integer)
    count_valid_data = DB.Column(DB.Integer)


@serializable
@geoserializable
class VmValidProfiles(DB.Model):
    __tablename__ = "vm_valid_profiles"
    __table_args__ = {"schema": "gn_profiles"}
    cd_ref = DB.Column(DB.Integer)
    valid_distribution = DB.Column(Geometry("GEOMETRY", current_app.config["LOCAL_SRID"]))
    altitude_min = DB.Column(DB.Integer)
    altitude_max = DB.Column(DB.Integer)
    first_valid_data = DB.Column(DB.DateTime)
    last_valid_data = DB.Column(DB.DateTime)
    count_valid_data = DB.Column(DB.Integer)
@@ -569,17 +569,16 @@
 teger)%0A%0A
-%0A
 @seriali
@@ -749,24 +749,42 @@
 n(DB.Integer
+, primary_key=True
 )%0A    valid_
@@ -1033,24 +1033,24 @@
 B.DateTime)%0A
-
     count_va
@@ -1061,28 +1061,567 @@
 data = DB.Column(DB.Integer)
+%0A%0A@serializable%0Aclass VConsistancyData(DB.Model):%0A    __tablename__ = %22v_consistancy_data%22%0A    __table_args__ = %7B%22schema%22: %22gn_profiles%22%7D%0A    id_synthese = DB.Column(DB.Integer, primary_key=True)%0A    id_sinp = unique_id_sinp = DB.Column(UUID(as_uuid=True))%0A    cd_ref = DB.Column(DB.Integer)%0A    valid_name = DB.Column(DB.Unicode)%0A    valid_distribution = DB.Column(DB.Boolean)%0A    valid_phenology = DB.Column(DB.Boolean)%0A    valid_altitude = DB.Column(DB.Boolean)%0A    score = DB.Column(DB.Integer)%0A    valid_status = DB.Column(DB.Unicode)

Add VConsistancyData model + PK