1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-08-31 15:11:08 +00:00

Fix the create table sqls.

This commit is contained in:
ly1217
2019-05-19 19:39:50 -07:00
parent 7ecb334194
commit b73e3ef989
7 changed files with 483 additions and 396 deletions

View File

@@ -1,228 +1,324 @@
CREATE TABLE `Branch` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
`repo_id` char(41) DEFAULT NULL,
`commit_id` char(41) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS Branch (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(10),
repo_id CHAR(41),
commit_id CHAR(41),
UNIQUE INDEX(repo_id, name)
) ENGINE = INNODB;
CREATE TABLE `GarbageRepos` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(36) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS FileLockTimestamp (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(40),
update_time BIGINT NOT NULL,
UNIQUE INDEX(repo_id)
);
CREATE TABLE `InnerPubRepo` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`permission` char(15) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS FileLocks (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(40) NOT NULL,
path TEXT NOT NULL,
user_name VARCHAR(255) NOT NULL,
lock_time BIGINT,
expire BIGINT,
KEY(repo_id)
) ENGINE=INNODB;
CREATE TABLE `OrgQuota` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`org_id` int(11) DEFAULT NULL,
`quota` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `org_id` (`org_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS FolderGroupPerm (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36) NOT NULL,
path TEXT NOT NULL,
permission CHAR(15),
group_id INTEGER NOT NULL,
INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE `OrgUserQuota` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`org_id` int(11) DEFAULT NULL,
`user` varchar(255) DEFAULT NULL,
`quota` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `org_id` (`org_id`,`user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS FolderPermTimestamp (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36),
timestamp BIGINT,
UNIQUE INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE `Repo` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS FolderUserPerm (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36) NOT NULL,
path TEXT NOT NULL,
permission CHAR(15),
user VARCHAR(255) NOT NULL,
INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE `RepoFileCount` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(36) DEFAULT NULL,
`file_count` bigint(20) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS GCID (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36),
gc_id CHAR(36),
UNIQUE INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE `RepoGroup` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`group_id` int(11) DEFAULT NULL,
`user_name` varchar(255) DEFAULT NULL,
`permission` char(15) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `group_id` (`group_id`,`repo_id`),
KEY `repo_id` (`repo_id`),
KEY `user_name` (`user_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS GarbageRepos (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36),
UNIQUE INDEX(repo_id)
);
CREATE TABLE `RepoHead` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`branch_name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS InnerPubRepo (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
permission CHAR(15),
UNIQUE INDEX (repo_id)
) ENGINE=INNODB;
CREATE TABLE `RepoHistoryLimit` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`days` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS LastGCID (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36),
client_id VARCHAR(128),
gc_id CHAR(36),
UNIQUE INDEX(repo_id, client_id)
) ENGINE=INNODB;
CREATE TABLE `RepoInfo` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(36) DEFAULT NULL,
`name` varchar(255) NOT NULL,
`update_time` bigint(20) DEFAULT NULL,
`version` int(11) DEFAULT NULL,
`is_encrypted` int(11) DEFAULT NULL,
`last_modifier` varchar(255) DEFAULT NULL,
`status` INTEGER DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS OrgGroupRepo (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
org_id INTEGER,
repo_id CHAR(37),
group_id INTEGER,
owner VARCHAR(255),
permission CHAR(15),
UNIQUE INDEX(org_id, group_id, repo_id),
INDEX (repo_id), INDEX (owner)
) ENGINE=INNODB;
CREATE TABLE `RepoOwner` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`owner_id` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`),
KEY `owner_id` (`owner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS OrgInnerPubRepo (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
org_id INTEGER,
repo_id CHAR(37),
UNIQUE INDEX(org_id, repo_id),
permission CHAR(15)
) ENGINE=INNODB;
CREATE TABLE `RepoSize` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`size` bigint(20) unsigned DEFAULT NULL,
`head_id` char(41) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS OrgQuota (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
org_id INTEGER,
quota BIGINT,
UNIQUE INDEX(org_id)
) ENGINE=INNODB;
CREATE TABLE `RepoTokenPeerInfo` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`token` char(41) DEFAULT NULL,
`peer_id` char(41) DEFAULT NULL,
`peer_ip` varchar(41) DEFAULT NULL,
`peer_name` varchar(255) DEFAULT NULL,
`sync_time` bigint(20) DEFAULT NULL,
`client_ver` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `token` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS OrgRepo (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
org_id INTEGER,
repo_id CHAR(37),
user VARCHAR(255),
UNIQUE INDEX(org_id, repo_id),
UNIQUE INDEX (repo_id),
INDEX (org_id, user),
INDEX(user)
) ENGINE=INNODB;
CREATE TABLE `RepoTrash` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(36) DEFAULT NULL,
`repo_name` varchar(255) DEFAULT NULL,
`head_id` char(40) DEFAULT NULL,
`owner_id` varchar(255) DEFAULT NULL,
`size` bigint(20) DEFAULT NULL,
`org_id` int(11) DEFAULT NULL,
`del_time` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`),
KEY `owner_id` (`owner_id`),
KEY `org_id` (`org_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS OrgSharedRepo (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
org_id INT,
repo_id CHAR(37) ,
from_email VARCHAR(255),
to_email VARCHAR(255),
permission CHAR(15),
INDEX(repo_id),
INDEX (org_id, repo_id),
INDEX(from_email), INDEX(to_email)
) ENGINE=INNODB;
CREATE TABLE `RepoUserToken` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`token` char(41) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`,`token`),
KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS OrgUserQuota (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
org_id INTEGER,
user VARCHAR(255),
quota BIGINT,
UNIQUE INDEX(org_id, user)
) ENGINE=INNODB;
CREATE TABLE `RepoValidSince` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`timestamp` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS Repo (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
UNIQUE INDEX (repo_id)
) ENGINE=INNODB;
CREATE TABLE `SeafileConf` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`cfg_group` varchar(255) NOT NULL,
`cfg_key` varchar(255) NOT NULL,
`value` varchar(255) DEFAULT NULL,
`property` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS RepoFileCount (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36),
file_count BIGINT UNSIGNED,
UNIQUE INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE `SharedRepo` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`from_email` varchar(255) DEFAULT NULL,
`to_email` varchar(255) DEFAULT NULL,
`permission` char(15) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `repo_id` (`repo_id`),
KEY `from_email` (`from_email`),
KEY `to_email` (`to_email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS RepoGroup (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
group_id INTEGER,
user_name VARCHAR(255),
permission CHAR(15),
UNIQUE INDEX(group_id, repo_id),
INDEX (repo_id), INDEX (user_name)
) ENGINE=INNODB;
CREATE TABLE `SystemInfo` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`info_key` varchar(256) DEFAULT NULL,
`info_value` varchar(1024) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS RepoHead (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
branch_name VARCHAR(10),
UNIQUE INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE `UserQuota` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user` varchar(255) DEFAULT NULL,
`quota` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS RepoHistoryLimit (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
days INTEGER,
UNIQUE INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE `UserShareQuota` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user` varchar(255) DEFAULT NULL,
`quota` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS RepoInfo (id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36),
name VARCHAR(255) NOT NULL,
update_time BIGINT,
version INTEGER,
is_encrypted INTEGER,
last_modifier VARCHAR(255),
status INTEGER DEFAULT 0,
UNIQUE INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE `VirtualRepo` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(36) DEFAULT NULL,
`origin_repo` char(36) DEFAULT NULL,
`path` text,
`base_commit` char(40) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`),
KEY `origin_repo` (`origin_repo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS RepoOwner (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
owner_id VARCHAR(255),
UNIQUE INDEX (repo_id),
INDEX (owner_id)
) ENGINE=INNODB;
CREATE TABLE `WebAP` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`repo_id` char(37) DEFAULT NULL,
`access_property` char(10) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `repo_id` (`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS RepoSize (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
size BIGINT UNSIGNED,
head_id CHAR(41),
UNIQUE INDEX (repo_id)
) ENGINE=INNODB;
CREATE TABLE `WebUploadTempFiles` (
`repo_id` char(40) NOT NULL,
`file_path` text NOT NULL,
`tmp_file_path` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS RepoStorageId (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(40) NOT NULL,
storage_id VARCHAR(255) NOT NULL,
UNIQUE INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS RepoSyncError (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
token CHAR(41),
error_time BIGINT UNSIGNED,
error_con VARCHAR(1024),
UNIQUE INDEX(token)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS RepoTokenPeerInfo (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
token CHAR(41),
peer_id CHAR(41),
peer_ip VARCHAR(41),
peer_name VARCHAR(255),
sync_time BIGINT,
client_ver VARCHAR(20),
UNIQUE INDEX(token)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS RepoTrash (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36),
repo_name VARCHAR(255),
head_id CHAR(40),
owner_id VARCHAR(255),
size BIGINT(20),
org_id INTEGER,
del_time BIGINT,
UNIQUE INDEX(repo_id),
INDEX(owner_id),
INDEX(org_id)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS RepoUserToken (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
email VARCHAR(255),
token CHAR(41),
UNIQUE INDEX(repo_id, token),
INDEX (email)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS RepoValidSince (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
timestamp BIGINT,
UNIQUE INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS RoleQuota (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
role VARCHAR(255),
quota BIGINT,
UNIQUE INDEX(role)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS SeafileConf (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
cfg_group VARCHAR(255) NOT NULL,
cfg_key VARCHAR(255) NOT NULL,
value VARCHAR(255),
property INTEGER
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS SharedRepo (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37) ,
from_email VARCHAR(255),
to_email VARCHAR(255),
permission CHAR(15),
INDEX (repo_id),
INDEX(from_email),
INDEX(to_email)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS SystemInfo (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
info_key VARCHAR(256),
info_value VARCHAR(1024)
);
CREATE TABLE IF NOT EXISTS UserQuota (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
user VARCHAR(255),
quota BIGINT,
UNIQUE INDEX(user)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS UserShareQuota (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
user VARCHAR(255),
quota BIGINT,
UNIQUE INDEX(user)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS VirtualRepo (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(36),
origin_repo CHAR(36),
path TEXT,
base_commit CHAR(40),
UNIQUE INDEX(repo_id),
INDEX(origin_repo)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS WebAP (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(37),
access_property CHAR(10),
UNIQUE INDEX(repo_id)
) ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS WebUploadTempFiles (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
repo_id CHAR(40) NOT NULL,
file_path TEXT NOT NULL,
tmp_file_path TEXT NOT NULL
) ENGINE=INNODB;