fix: SystemAlert @PrePersist override + types_reference complete schema in V1
- SystemAlert.onCreate() now calls super.onCreate() to set dateCreation (was null → NOT NULL violation every minute) - V1: types_reference updated with full schema (domaine, est_defaut, est_systeme, ordre_affichage, modules_requis, organisation_id) - V9: idempotent guard for categorie nullable ALTER (already nullable in updated V1)
This commit is contained in:
@@ -108,6 +108,7 @@ public class SystemAlert extends BaseEntity {
|
||||
*/
|
||||
@PrePersist
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
if (timestamp == null) {
|
||||
timestamp = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@@ -1055,16 +1055,23 @@ CREATE TABLE IF NOT EXISTS ayants_droit (
|
||||
-- Table types_reference
|
||||
CREATE TABLE IF NOT EXISTS types_reference (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
domaine VARCHAR(50) NOT NULL,
|
||||
code VARCHAR(50) NOT NULL,
|
||||
categorie VARCHAR(50) NOT NULL,
|
||||
categorie VARCHAR(50),
|
||||
libelle VARCHAR(200) NOT NULL,
|
||||
description TEXT,
|
||||
ordre INTEGER DEFAULT 0,
|
||||
ordre_affichage INTEGER NOT NULL DEFAULT 0,
|
||||
est_defaut BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
est_systeme BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
modules_requis VARCHAR(500),
|
||||
organisation_id UUID,
|
||||
date_creation TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
date_modification TIMESTAMP,
|
||||
version BIGINT DEFAULT 0,
|
||||
actif BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
CONSTRAINT uk_type_ref UNIQUE (categorie, code)
|
||||
cree_par VARCHAR(255),
|
||||
modifie_par VARCHAR(255),
|
||||
CONSTRAINT uk_typeref_domaine_code_org UNIQUE (domaine, code, organisation_id)
|
||||
);
|
||||
|
||||
-- Table modules_organisation_actifs
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
-- no longer includes this column, causing INSERT to fail with NOT NULL violation.
|
||||
-- Also drop the old unique constraint on (categorie, code) which references the old design.
|
||||
|
||||
ALTER TABLE types_reference ALTER COLUMN categorie DROP NOT NULL;
|
||||
-- categorie is already nullable in V1 (updated schema), these are idempotent safety guards
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='types_reference' AND column_name='categorie' AND is_nullable='NO') THEN
|
||||
ALTER TABLE types_reference ALTER COLUMN categorie DROP NOT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
ALTER TABLE types_reference DROP CONSTRAINT IF EXISTS uk_type_ref;
|
||||
|
||||
Reference in New Issue
Block a user