Ho un sito per il quale sono necessarie delle tabelle del tipo
Praticamente, alla creazione del record, created_at ed updated_at devono riportare il timestamp corrente, quando un record viene aggiornato, il campo updated_at deve automaticamente essere impostato al timestamp dell'aggiornamento.codice:CREATE TABLE `category_user` ( `user_id` int(10) UNSIGNED NOT NULL, `category_id` int(10) UNSIGNED NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Ma sul server che deve ospitale c'è la versione 5.5.41 di MySQL che restituisce l'errore
La dichiarazione della tabella sarebbe lecita dalla versione 5.6 di MySQL, ma non è disponibile.#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
C'è un modo compatibile con MySQL 5.5 per ottenere lo stesso risultato?

Rispondi quotando
