[GITINFO] Creating the table with DEFAULT CURRENT_TIMESTAMP removes the "on update CURRENT_TIMESTAMP" at least.

This is still not really what I want, but less of a hack and causes no harm if we ever migrate the database to another server.

svn path=/trunk/; revision=1008
This commit is contained in:
Colin Finck 2017-10-05 10:39:04 +00:00
parent f512b673da
commit c25a651da4

View File

@ -5,19 +5,12 @@ CREATE TABLE `master_revisions` (
`rev_hash` char(40) NOT NULL,
`author_name` varchar(100) NOT NULL,
`author_email` varchar(100) NOT NULL,
`commit_timestamp` timestamp NOT NULL,
`commit_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`message` blob NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `rev_hash` (`rev_hash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
-- MySQL always creates timestamp columns with a default value and "on update CURRENT_TIMESTAMP".
-- This is the dirty hack to remove them again (from https://stackoverflow.com/a/31865524).
-- Even exporting the table structure through mysqldump and importing it again results in these unwanted extras...
ALTER TABLE `master_revisions` CHANGE COLUMN `commit_timestamp` `commit_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE `master_revisions` ALTER COLUMN `commit_timestamp` DROP DEFAULT;
CREATE TABLE `master_revisions_todo` (
`oldrev` char(40) NOT NULL,
`newrev` char(40) NOT NULL,