CREATE TABLE tx_horaire (
id INT AUTO_INCREMENT NOT NULL,
tx_trf_id INT DEFAULT NULL,
tx_vhc_cat_id INT DEFAULT NULL,
hr_date_depart DATETIME DEFAULT NULL,
hr_date_arrivee DATETIME DEFAULT NULL,
hr_date_retour DATETIME DEFAULT NULL,
hr_extra VARCHAR(255) DEFAULT NULL,
INDEX IDX_FDF12FFB7582DD89 (tx_trf_id),
INDEX IDX_FDF12FFB7C436EFD (tx_vhc_cat_id),
PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;

CREATE TABLE tx_reservation (
id INT AUTO_INCREMENT NOT NULL,
tx_hr_id INT DEFAULT NULL,
tx_usr_id INT DEFAULT NULL,
rsv_description VARCHAR(255) DEFAULT NULL,
rsv_num_transaction VARCHAR(100) DEFAULT NULL,
rsv_extra TINYTEXT DEFAULT NULL,
rsv_nbr_adulte INT DEFAULT NULL,
rsv_nbr_enfant INT DEFAULT NULL,
rsv_bagage VARCHAR(255) DEFAULT NULL,
rsv_is_payed TINYINT(1) DEFAULT NULL,
rsv_is_facture TINYINT(1) DEFAULT NULL,
rsv_is_valid TINYINT(1) DEFAULT NULL,
rsv_is_cash TINYINT(1) DEFAULT NULL,
INDEX IDX_A52FD7B49E132CD4 (tx_hr_id),
INDEX IDX_A52FD7B45CC5E754 (tx_usr_id),
PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;

ALTER TABLE tx_horaire
ADD CONSTRAINT FK_FDF12FFB7582DD89 FOREIGN KEY (tx_trf_id) REFERENCES tx_tarif (id) ON DELETE SET NULL;

ALTER TABLE tx_horaire
ADD CONSTRAINT FK_FDF12FFB7C436EFD FOREIGN KEY (tx_vhc_cat_id) REFERENCES tx_reduction_type (id) ON DELETE SET NULL;

ALTER TABLE tx_reservation
ADD CONSTRAINT FK_A52FD7B49E132CD4 FOREIGN KEY (tx_hr_id) REFERENCES tx_horaire (id) ON DELETE SET NULL;

ALTER TABLE tx_reservation
ADD CONSTRAINT FK_A52FD7B45CC5E754 FOREIGN KEY (tx_usr_id) REFERENCES tx_user (id) ON DELETE CASCADE;
