From 32a5c24ba29f531d69de77a4221d5d89a765ef2b Mon Sep 17 00:00:00 2001 From: andre Date: Fri, 25 Sep 2026 12:44:07 +0100 Subject: [PATCH] =?UTF-8?q?feat(db):=20created=5Fat=20nas=207=20tabelas=20?= =?UTF-8?q?que=20n=C3=A3o=20tinham=20(auditoria=203.1.5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fitme3070_info, galleries, horario, modalidades, system_settings, website_offer e work_hours passam a ter created_at (DEFAULT CURRENT_TIMESTAMP, linhas existentes ficam com a data da migração). Sem created_by de propósito: são o CRUD de um só admin e a audit_log (ligada 2026-09-25) já regista quem criou/mudou cada linha. Co-Authored-By: Claude Sonnet 5 --- database/migration_20260925_created_at.sql | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 database/migration_20260925_created_at.sql diff --git a/database/migration_20260925_created_at.sql b/database/migration_20260925_created_at.sql new file mode 100644 index 0000000..2702b00 --- /dev/null +++ b/database/migration_20260925_created_at.sql @@ -0,0 +1,25 @@ +-- ─── created_at nas tabelas que ainda não têm ──────────────────────────────── +-- Auditoria 2026-09-24, ponto 3.1.5: fitme3070_info, galleries, horario, +-- modalidades, system_settings, website_offer e work_hours não registam +-- quando uma linha foi criada. Sem isso, uma fila de definições antigas ou +-- uma modalidade que já lá estava no dia 1 é indistinguível de uma criada +-- ontem. +-- +-- Sem created_by de propósito: estas sete são o CRUD de um só admin (a +-- audit_log, ligada em 2026-09-25, já regista quem criou/mudou cada linha — +-- ver config/functions_audit.php). Uma coluna created_by aqui seria uma +-- segunda fonte da mesma resposta, sem valor a mais. +-- +-- DEFAULT CURRENT_TIMESTAMP em vez de NULL: as linhas já existentes ficam com +-- a data da migração (a única data honesta disponível), e nenhum INSERT +-- existente que não mencione created_at parte. +-- +-- Safe to re-run (IF NOT EXISTS é extensão do MariaDB). + +ALTER TABLE `fitme3070_info` ADD COLUMN IF NOT EXISTS `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `id`; +ALTER TABLE `galleries` ADD COLUMN IF NOT EXISTS `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `name`; +ALTER TABLE `horario` ADD COLUMN IF NOT EXISTS `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `local`; +ALTER TABLE `modalidades` ADD COLUMN IF NOT EXISTS `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `gym_id`; +ALTER TABLE `system_settings` ADD COLUMN IF NOT EXISTS `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `setting_value`; +ALTER TABLE `website_offer` ADD COLUMN IF NOT EXISTS `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `gym_id`; +ALTER TABLE `work_hours` ADD COLUMN IF NOT EXISTS `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `gym_id`;