/* continue_if_error   */
alter table INDIVIDU add BADGE_OUBLI_N_MAX integer;

/* continue_if_error  */
alter table INDIVIDU add BADGE_OUBLI_PASS varchar(6);
/* continue_if_error  */
alter table REGIME add BADGE_OUBLI_N_MAX integer;

/* continue_if_error  */
drop table BADGE_OUBLI_INDIVIDU;
create table BADGE_OUBLI_INDIVIDU
(
INDIVIDU integer not null,
TRIMESTRE integer not null,
ANNEE integer not null,
NPASSAGE integer,

CONSTRAINT "PK_OUBLI_INDIVIDU" PRIMARY KEY ("INDIVIDU","TRIMESTRE","ANNEE")
);

/* continue_if_error  */
ALTER TABLE "BADGE_OUBLI_INDIVIDU" ADD CONSTRAINT "FK_OUBLI_REF_INDIVIDU" FOREIGN KEY ("INDIVIDU") REFERENCES INDIVIDU ("ID") ON DELETE CASCADE;

commit;

/*  continue_if_error */
create TABLE BADGE_OUBLI_PASSAGE
(
  NUM integer not null, 
  INDIVIDU Integer NOT NULL,
  BADGE varchar(14) not null,
  JOURHEURE_CREATE TIMESTAMP,
  JOURHEURE_PASSAGE TIMESTAMP,
  N_TICKET_PRINTED integer,
  CONSTRAINT BADGE_OUBLI_PASSAGE PRIMARY KEY (num)
);

/* continue_if_error  */
ALTER TABLE BADGE_OUBLI_PASSAGE ADD CONSTRAINT FK_BADGE_OUBLI_PASSAGE_INDIV
  FOREIGN KEY (INDIVIDU) REFERENCES INDIVIDU (ID) on delete cascade;
 
/* continue_if_error  */
create generator BADGE_OUBLI_PASSAGE;

/* continue_if_error  */
alter table PARAMETRES_GENERAUX add BADGE_OUBLI_MAX_PRINT integer;
update PARAMETRES_GENERAUX set BADGE_OUBLI_MAX_PRINT = 3;

/* continue_if_error  */
alter table PARAMETRES_GENERAUX add BADGE_OUBLI_MOIS T_BOOL;
update PARAMETRES_GENERAUX set BADGE_OUBLI_MOIS = 0;

/* continue_if_error  */
alter table PARAMETRES_GENERAUX add BADGE_OUBLI_NOLIMIT_TICKET T_BOOL;
update PARAMETRES_GENERAUX set BADGE_OUBLI_NOLIMIT_TICKET = 0;

