/*
* phpMyEdit - instant MySQL table editor and code generator
*
* examples/pme_changelog.sql - create audit log table for action audit
* ____________________________________________________________________
*
* Copyright (c) 1999-2002 John McCreesh <jpmcc@users.sourceforge.net>
* Copyright (c) 2001-2002 Jim Kraai <jkraai@users.sourceforge.net>
* Versions 5.0 and higher developed by Ondrej Jombik <nepto@php.net>
* Versions 5.7.2 and higher developed by Yves De Billoëz
* Copyright (c) 2002-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README.md file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* https://sourceforge.net/projects/phpmariaedit/
*/
/* $Platon: phpMyEdit/examples/pme_changelog.sql,v 5.7.6 2024-03-01 12:57:07 Yves $ */
/* table definition for pme_changelog table from documentation, please note
that the `updated` field has been changed from NULL to CURRENT_TIMESTAMP
for its default value, changed its size as well,
please also note backticks have been used on all fields
*/
CREATE TABLE `pme_changelog` (
`updated` timestamp default CURRENT_TIMESTAMP,
`user` varchar(255) default NULL,
`host` varchar(255) default NULL,
`operation` varchar(255) default NULL,
`tab` varchar(255) default NULL,
`rowkey` varchar(255) default NULL,
`col` varchar(255) default NULL,
`oldval` blob default NULL,
`newval` blob default NULL
);
/* following statements are updates to the table structure that are different
from the documentation
*/
ALTER TABLE `pme_changelog`
COMMENT = 'all changes done by user using phpMyEdit are logged in this table';
/* follopwing statement creates a unique ID on the table,
this would not be required when using a database other than
mysql
*/
ALTER TABLE `pme_changelog`
ADD `rowid` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY FIRST;
/* mysql uses longblob instead of blob for unlimited storage,
it could be required depending on your database model.
It is more safe to use longblob instead of blob.
*/
ALTER TABLE `pme_changelog` MODIFY COLUMN `oldval` LONGBLOB;
ALTER TABLE `pme_changelog` MODIFY COLUMN `newval` LONGBLOB;
/* change length from 14 to default, and also update value if record
is modified
*/
ALTER TABLE `pme_changelog`
MODIFY `updated` timestamp NOT NULL DEFAULT current_timestamp()
ON UPDATE current_timestamp();
INSERT INTO `pme_changelog`
(`user`, `operation`)
VALUES
('table creation script', 'table creation');
/*
-- trigger in compatible format for other databases (not MySQL)
-- please refer to examples for more advanced implementations
DROP TRIGGER IF EXISTS `pme_changelog_before_insert`;
CREATE TRIGGER `pme_changelog_before_insert` BEFORE INSERT ON `pme_changelog`
FOR EACH ROW
SET NEW.updated := current_timestamp();
*/
/* after creating the table, add following statement to the configuration
$opts['logtable'] = 'pme_changelog';
*/
/* eof */