Now the db schema of this extension is created by processing a sql file
This commit is contained in:
parent
f0fe255f48
commit
4ce7de723a
|
@ -18,45 +18,37 @@
|
|||
function pandora_files_repo_install () {
|
||||
global $config;
|
||||
|
||||
|
||||
if (isset($config['files_repo_installed'])) {
|
||||
if ($config['files_repo_installed'] == 1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['files_repo_installed']) && $config['files_repo_installed'] == 1)
|
||||
return;
|
||||
|
||||
$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/";
|
||||
$full_sql_dir = $full_extensions_dir."files_repo/sql/";
|
||||
|
||||
/* SQL installation */
|
||||
$file_path = '';
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
$sentences = file ($full_sql_dir.'files_repo.sql');
|
||||
case "mysql":
|
||||
$file_path = $full_sql_dir . 'files_repo.sql';
|
||||
break;
|
||||
case 'postgresql':
|
||||
$sentences = file ($full_sql_dir.'files_repo.postgreSQL.sql');
|
||||
case "postgresql":
|
||||
$file_path = $full_sql_dir . 'files_repo.postgreSQL.sql';
|
||||
break;
|
||||
case 'oracle':
|
||||
$sentences = file ($full_sql_dir.'files_repo.oracle.sql');
|
||||
case "oracle":
|
||||
$file_path = $full_sql_dir . 'files_repo.oracle.sql';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
foreach ($sentences as $sentence) {
|
||||
if (trim ($sentence) == "")
|
||||
continue;
|
||||
$success = db_process_sql ($sentence);
|
||||
if ($success === false)
|
||||
return;
|
||||
if (!empty($file_path)) {
|
||||
$result = db_process_file($file_path);
|
||||
|
||||
if ($result) {
|
||||
/* Configuration values */
|
||||
$values = array(
|
||||
"token" => "files_repo_installed",
|
||||
"value" => 1
|
||||
);
|
||||
db_process_sql_insert('tconfig', $values);
|
||||
}
|
||||
}
|
||||
|
||||
/* Configuration values */
|
||||
$values = array(
|
||||
"token" => "files_repo_installed",
|
||||
"value" => 1
|
||||
);
|
||||
db_process_sql_insert('tconfig', $values);
|
||||
}
|
||||
|
||||
function pandora_files_repo_uninstall () {
|
||||
|
@ -76,7 +68,11 @@ function pandora_files_repo_uninstall () {
|
|||
WHERE "token" LIKE \'files_repo_%\'');
|
||||
break;
|
||||
case "oracle":
|
||||
db_process_sql('DROP TRIGGER "tfiles_repo_group_inc"');
|
||||
db_process_sql('DROP SEQUENCE "tfiles_repo_group_s"');
|
||||
db_process_sql('DROP TABLE "tfiles_repo_group"');
|
||||
db_process_sql('DROP TRIGGER "tfiles_repo_inc"');
|
||||
db_process_sql('DROP SEQUENCE "tfiles_repo_s"');
|
||||
db_process_sql('DROP TABLE "tfiles_repo"');
|
||||
db_process_sql('DELETE FROM tconfig
|
||||
WHERE token LIKE \'files_repo_%\'');
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
CREATE TABLE IF NOT EXISTS tfiles_repo (id NUMBER(5, 0) NOT NULL PRIMARY KEY, name VARCHAR(255) NOT NULL, description VARCHAR(500) NULL default '', hash VARCHAR(8) NULL default '');
|
||||
CREATE TABLE tfiles_repo (
|
||||
id NUMBER(5, 0) NOT NULL PRIMARY KEY,
|
||||
name VARCHAR2(255) NOT NULL,
|
||||
description VARCHAR2(500) NULL,
|
||||
hash VARCHAR2(8) NULL
|
||||
);
|
||||
CREATE SEQUENCE tfiles_repo_s INCREMENT BY 1 START WITH 1;
|
||||
CREATE OR REPLACE TRIGGER tfiles_repo_inc BEFORE INSERT ON tfiles_repo REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tfiles_repo_s.nextval INTO :NEW.ID FROM dual; END;;
|
||||
CREATE TABLE IF NOT EXISTS tfiles_repo_group (id NUMBER(10, 0) NOT NULL PRIMARY KEY, id_file NUMBER(5, 0) NOT NULL REFERENCES tfiles_repo(id) ON DELETE CASCADE, id_group NUMBER(4, 0) NOT NULL);
|
||||
CREATE SEQUENCE tfiles_repo_profile_s INCREMENT BY 1 START WITH 1;
|
||||
|
||||
CREATE TABLE tfiles_repo_group (
|
||||
id NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
||||
id_file NUMBER(5, 0) NOT NULL REFERENCES tfiles_repo(id) ON DELETE CASCADE,
|
||||
id_group NUMBER(4, 0) NOT NULL
|
||||
);
|
||||
CREATE SEQUENCE tfiles_repo_group_s INCREMENT BY 1 START WITH 1;
|
||||
CREATE OR REPLACE TRIGGER tfiles_repo_group_inc BEFORE INSERT ON tfiles_repo_group REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tfiles_repo_group_s.nextval INTO :NEW.ID FROM dual; END;;
|
|
@ -1,2 +1,15 @@
|
|||
CREATE TABLE IF NOT EXISTS `tfiles_repo` (`id` int(5) unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL, `description` varchar(500) NULL default '', `hash` varchar(8) NULL default '', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `tfiles_repo_group` (`id` int(10) unsigned NOT NULL auto_increment, `id_file` int(5) unsigned NOT NULL, `id_group` int(4) unsigned NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (`id_file`) REFERENCES tfiles_repo(`id`) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `tfiles_repo` (
|
||||
`id` int(5) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` varchar(500) NULL default '',
|
||||
`hash` varchar(8) NULL default '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tfiles_repo_group` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_file` int(5) unsigned NOT NULL,
|
||||
`id_group` int(4) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_file`) REFERENCES tfiles_repo(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
Loading…
Reference in New Issue