This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 293
/
create.mysql
38 lines (31 loc) · 1.58 KB
/
create.mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
CREATE TABLE IF NOT EXISTS `ajxp_changes` (
`seq` int(20) NOT NULL AUTO_INCREMENT,
`repository_identifier` TEXT NOT NULL,
`node_id` bigint(20) NOT NULL,
`type` enum('create','delete','path','content') NOT NULL,
`source` text NOT NULL,
`target` text NOT NULL,
PRIMARY KEY (`seq`),
KEY `node_id` (`node_id`,`type`)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `ajxp_index` (
`node_id` int(20) NOT NULL AUTO_INCREMENT,
`node_path` text NOT NULL,
`bytesize` bigint(20) NOT NULL,
`md5` varchar(32) NOT NULL,
`mtime` int(11) NOT NULL,
`repository_identifier` text NOT NULL,
PRIMARY KEY (`node_id`)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TRIGGER IF EXISTS `LOG_DELETE`;
CREATE TRIGGER `LOG_DELETE` AFTER DELETE ON `ajxp_index`
FOR EACH ROW INSERT INTO ajxp_changes (repository_identifier, node_id,source,target,type)
VALUES (old.repository_identifier, old.node_id, old.node_path, 'NULL', 'delete');
DROP TRIGGER IF EXISTS `LOG_INSERT`;
CREATE TRIGGER `LOG_INSERT` AFTER INSERT ON `ajxp_index`
FOR EACH ROW INSERT INTO ajxp_changes (repository_identifier, node_id,source,target,type)
VALUES (new.repository_identifier, new.node_id, 'NULL', new.node_path, 'create');
DROP TRIGGER IF EXISTS `LOG_UPDATE`;
CREATE TRIGGER `LOG_UPDATE` AFTER UPDATE ON `ajxp_index`
FOR EACH ROW INSERT INTO ajxp_changes (repository_identifier, node_id,source,target,type)
VALUES (new.repository_identifier, new.node_id, old.node_path, new.node_path, CASE old.node_path COLLATE utf8_bin = new.node_path COLLATE utf8_bin WHEN true THEN 'content' ELSE 'path' END);