Remove measure importance
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -29,17 +29,16 @@ import (
|
||||
|
||||
type (
|
||||
Mesure struct {
|
||||
ID gid.GID `db:"id"`
|
||||
TenantID gid.TenantID `db:"tenant_id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
Category string `db:"category"`
|
||||
Name string `db:"name"`
|
||||
Description string `db:"description"`
|
||||
Importance MesureImportance `db:"importance"`
|
||||
State MesureState `db:"state"`
|
||||
ReferenceID string `db:"reference_id"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
TenantID gid.TenantID `db:"tenant_id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
Category string `db:"category"`
|
||||
Name string `db:"name"`
|
||||
Description string `db:"description"`
|
||||
State MesureState `db:"state"`
|
||||
ReferenceID string `db:"reference_id"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
Mesures []*Mesure
|
||||
@@ -71,7 +70,6 @@ WITH msrs AS (
|
||||
m.name,
|
||||
m.description,
|
||||
m.state,
|
||||
m.importance,
|
||||
m.reference_id,
|
||||
m.created_at,
|
||||
m.updated_at
|
||||
@@ -90,7 +88,6 @@ SELECT
|
||||
name,
|
||||
description,
|
||||
state,
|
||||
importance,
|
||||
reference_id,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -137,7 +134,6 @@ WITH mtgtns AS (
|
||||
m.name,
|
||||
m.description,
|
||||
m.state,
|
||||
m.importance,
|
||||
m.reference_id,
|
||||
m.created_at,
|
||||
m.updated_at
|
||||
@@ -156,7 +152,6 @@ SELECT
|
||||
name,
|
||||
description,
|
||||
state,
|
||||
importance,
|
||||
reference_id,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -202,7 +197,6 @@ SELECT
|
||||
name,
|
||||
description,
|
||||
state,
|
||||
importance,
|
||||
reference_id,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -249,7 +243,6 @@ SELECT
|
||||
name,
|
||||
description,
|
||||
state,
|
||||
importance,
|
||||
reference_id,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -294,7 +287,6 @@ INSERT INTO
|
||||
organization_id,
|
||||
category,
|
||||
name,
|
||||
importance,
|
||||
state,
|
||||
description,
|
||||
reference_id,
|
||||
@@ -307,7 +299,6 @@ VALUES (
|
||||
@organization_id,
|
||||
@category,
|
||||
@name,
|
||||
@importance,
|
||||
@state,
|
||||
@description,
|
||||
@reference_id,
|
||||
@@ -339,7 +330,6 @@ RETURNING
|
||||
"organization_id": m.OrganizationID,
|
||||
"category": m.Category,
|
||||
"name": m.Name,
|
||||
"importance": m.Importance,
|
||||
"state": m.State,
|
||||
"description": m.Description,
|
||||
"reference_id": m.ReferenceID,
|
||||
@@ -375,7 +365,6 @@ INSERT INTO
|
||||
organization_id,
|
||||
category,
|
||||
name,
|
||||
importance,
|
||||
state,
|
||||
description,
|
||||
reference_id,
|
||||
@@ -388,7 +377,6 @@ VALUES (
|
||||
@organization_id,
|
||||
@category,
|
||||
@name,
|
||||
@importance,
|
||||
@state,
|
||||
@description,
|
||||
@reference_id,
|
||||
@@ -408,7 +396,6 @@ VALUES (
|
||||
"created_at": m.CreatedAt,
|
||||
"updated_at": m.UpdatedAt,
|
||||
"state": m.State,
|
||||
"importance": m.Importance,
|
||||
}
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
return err
|
||||
@@ -426,7 +413,6 @@ SET
|
||||
description = @description,
|
||||
category = @category,
|
||||
state = @state,
|
||||
importance = @importance,
|
||||
updated_at = @updated_at
|
||||
WHERE %s
|
||||
AND id = @mesure_id
|
||||
@@ -439,7 +425,6 @@ WHERE %s
|
||||
"description": m.Description,
|
||||
"category": m.Category,
|
||||
"state": m.State,
|
||||
"importance": m.Importance,
|
||||
"updated_at": m.UpdatedAt,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type MesureImportance uint8
|
||||
|
||||
const (
|
||||
MesureImportanceMandatory MesureImportance = iota
|
||||
MesureImportancePreferred
|
||||
MesureImportanceAdvanced
|
||||
)
|
||||
|
||||
func (i MesureImportance) String() string {
|
||||
return []string{"MANDATORY", "PREFERRED", "ADVANCED"}[i]
|
||||
}
|
||||
|
||||
func (i *MesureImportance) Scan(value interface{}) error {
|
||||
switch v := value.(type) {
|
||||
case uint8:
|
||||
*i = MesureImportance(v)
|
||||
case string:
|
||||
switch v {
|
||||
case "MANDATORY":
|
||||
*i = MesureImportanceMandatory
|
||||
case "PREFERRED":
|
||||
*i = MesureImportancePreferred
|
||||
case "ADVANCED":
|
||||
*i = MesureImportanceAdvanced
|
||||
default:
|
||||
return fmt.Errorf("invalid MesureImportance value: %q", v)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for MesureImportance: %T", value)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i MesureImportance) Value() (driver.Value, error) {
|
||||
return i.String(), nil
|
||||
}
|
||||
|
||||
func (i MesureImportance) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(i.String())
|
||||
}
|
||||
|
||||
func (i *MesureImportance) UnmarshalJSON(data []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "MANDATORY":
|
||||
*i = MesureImportanceMandatory
|
||||
case "PREFERRED":
|
||||
*i = MesureImportancePreferred
|
||||
case "ADVANCED":
|
||||
*i = MesureImportanceAdvanced
|
||||
default:
|
||||
return fmt.Errorf("invalid MesureImportance value: %q", s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *MesureImportance) UnmarshalText(text []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(text, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "MANDATORY":
|
||||
*i = MesureImportanceMandatory
|
||||
case "PREFERRED":
|
||||
*i = MesureImportancePreferred
|
||||
case "ADVANCED":
|
||||
*i = MesureImportanceAdvanced
|
||||
default:
|
||||
return fmt.Errorf("invalid MesureImportance value: %q", s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
1
pkg/coredata/migrations/20250427T082100Z.sql
Normal file
1
pkg/coredata/migrations/20250427T082100Z.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE mesures DROP COLUMN importance;
|
||||
Reference in New Issue
Block a user