Skip to content

Commit

Permalink
Merge pull request Third-Culture-Software#7819 from jniles/7817-add-t…
Browse files Browse the repository at this point in the history
…imestamps-to-employee-table

chore(employee): add timestamps to employee table

All tests pass.
  • Loading branch information
jmcameron authored Oct 24, 2024
2 parents 1903d09 + 29ab4df commit 1ff6476
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/models/01-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ CREATE TABLE `employee` (
`patient_uuid` BINARY(16) DEFAULT NULL,
`reference` SMALLINT(5) UNSIGNED DEFAULT NULL,
`title_employee_id` TINYINT(3) UNSIGNED DEFAULT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`uuid`),
UNIQUE KEY `employee_1` (`code`),
UNIQUE KEY `employee_2` (`patient_uuid`),
Expand Down
13 changes: 13 additions & 0 deletions server/models/migrations/next/migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,16 @@ ALTER TABLE `period` MODIFY `locked` TINYINT(1) NOT NULL DEFAULT 0;
ALTER TABLE `period_total` MODIFY `locked` TINYINT(1) NOT NULL DEFAULT 0;
ALTER TABLE `project` MODIFY `locked` TINYINT(1) NOT NULL DEFAULT 0;
ALTER TABLE `supplier` MODIFY `locked` TINYINT(1) NOT NULL DEFAULT 0;

-- @jniles
-- 2024-10-23
-- add timestamps to the employee table for better tracking.
ALTER TABLE `employee` ADD COLUMN `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE `employee` ADD COLUMN `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

-- default the "created_at" to the "date_embauche" from previous records.
UPDATE `employee` SET created_at = date_embauche;
UPDATE `employee` SET updated_at = date_embauche;



0 comments on commit 1ff6476

Please sign in to comment.