mirror of
https://github.com/xevidos/codiad.git
synced 2024-12-23 06:12:16 +01:00
Adapting install process to support postgresql
This commit is contained in:
parent
53026ba69e
commit
c1db00a938
1 changed files with 73 additions and 3 deletions
|
@ -94,6 +94,17 @@ if ( ! ( defined( "DBHOST" ) && defined( "DBNAME" ) && defined( "DBUSER" ) && de
|
|||
$dbuser = $_POST['dbuser'];
|
||||
$dbpass = $_POST['dbpass'];
|
||||
|
||||
//Valid databases Codiad is able to use
|
||||
$aValidDBType = [
|
||||
'mysql'
|
||||
,'postgresql'
|
||||
];
|
||||
|
||||
//Is selected database type valid?
|
||||
if(!in_array($dbtype,$aValidDBType)){
|
||||
die( "Invalid database. Please select one of ".implode(", "$aValidDBType)."." );
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$connection = new PDO( "{$dbtype}:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass );
|
||||
|
@ -104,7 +115,8 @@ if ( ! ( defined( "DBHOST" ) && defined( "DBNAME" ) && defined( "DBUSER" ) && de
|
|||
}
|
||||
$bind_vars = array();
|
||||
$bind = "";
|
||||
$sql = "
|
||||
$sql = [];
|
||||
$sql['mysql'] = "
|
||||
|
||||
--
|
||||
-- Table structure for table options
|
||||
|
@ -164,11 +176,69 @@ CREATE TABLE IF NOT EXISTS user_options (
|
|||
CONSTRAINT option_name UNIQUE (name,username)
|
||||
);
|
||||
|
||||
";
|
||||
|
||||
$sql['postgresql'] = "
|
||||
|
||||
--
|
||||
-- Table structure for table options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS options (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL UNIQUE,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table projects
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS projects (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
path varchar(255) NOT NULL UNIQUE,
|
||||
owner varchar(255) NOT NULL UNIQUE,
|
||||
access text
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table users
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
first_name varchar(255) DEFAULT NULL,
|
||||
last_name varchar(255) DEFAULT NULL,
|
||||
username varchar(255) NOT NULL UNIQUE,
|
||||
password text NOT NULL,
|
||||
email varchar(255) DEFAULT NULL,
|
||||
project varchar(255) DEFAULT NULL,
|
||||
access varchar(255) NOT NULL,
|
||||
groups text,
|
||||
token text
|
||||
);
|
||||
|
||||
--
|
||||
-- Table structure for table user_options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_options (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL UNIQUE,
|
||||
username varchar(255) NOT NULL UNIQUE,
|
||||
value text NOT NULL
|
||||
);
|
||||
|
||||
";
|
||||
|
||||
try {
|
||||
|
||||
$result = $connection->exec($sql);
|
||||
$result = $connection->exec($sql[$dbtype]);
|
||||
} catch( PDOException $e ) {
|
||||
|
||||
die($e->getMessage());
|
||||
|
|
Loading…
Reference in a new issue