1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-19 06:50:07 +03:00

feature #206: SQL Table creation queries modified to include IF NOT EXISTS

This commit is contained in:
Carlos Martín 2010-05-06 12:31:09 +02:00 committed by Ruben S. Montero
parent 0bf7092ffc
commit ebfd201bdc
10 changed files with 18 additions and 15 deletions

View File

@ -55,7 +55,7 @@ const char * Host::table = "host_pool";
const char * Host::db_names = "(oid,host_name,state,im_mad,vm_mad,"
"tm_mad,last_mon_time)";
const char * Host::db_bootstrap = "CREATE TABLE host_pool ("
const char * Host::db_bootstrap = "CREATE TABLE IF NOT EXISTS host_pool ("
"oid INTEGER PRIMARY KEY,host_name VARCHAR(512), state INTEGER,"
"im_mad VARCHAR(128),vm_mad VARCHAR(128),tm_mad VARCHAR(128),"
"last_mon_time INTEGER, UNIQUE(host_name, im_mad, vm_mad, tm_mad) )";

View File

@ -63,8 +63,8 @@ const char * HostShare::db_names = "(hid,"
"used_disk, used_mem, used_cpu,"
"running_vms)";
const char * HostShare::db_bootstrap = "CREATE TABLE host_shares ("
"hid INTEGER PRIMARY KEY,"
const char * HostShare::db_bootstrap = "CREATE TABLE IF NOT EXISTS host_shares("
"hid INTEGER PRIMARY KEY,"
"disk_usage INTEGER, mem_usage INTEGER, cpu_usage INTEGER,"
"max_disk INTEGER, max_mem INTEGER, max_cpu INTEGER,"
"free_disk INTEGER, free_mem INTEGER, free_cpu INTEGER,"

View File

@ -18,7 +18,7 @@
const char * HostTemplate::table = "host_attributes";
const char * HostTemplate::db_bootstrap = "CREATE TABLE host_attributes"
" (id INTEGER, name VARCHAR(256), type INTEGER, value TEXT, "
const char * HostTemplate::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
"host_attributes (id INTEGER, name VARCHAR(256), type INTEGER, value TEXT, "
"PRIMARY KEY(id,name))";

View File

@ -52,7 +52,7 @@ const char * User::table = "user_pool";
const char * User::db_names = "(oid,user_name,password,enabled)";
const char * User::db_bootstrap = "CREATE TABLE user_pool ("
const char * User::db_bootstrap = "CREATE TABLE IF NOT EXISTS user_pool ("
"oid INTEGER PRIMARY KEY, user_name VARCHAR(256), password TEXT,"
"enabled INTEGER, UNIQUE(user_name))";

View File

@ -28,11 +28,12 @@ const char * History::table = "history";
const char * History::db_names = "(vid,seq,host_name,vm_dir,hid,vm_mad,tm_mad,stime,"
"etime,pstime,petime,rstime,retime,estime,eetime,reason)";
const char * History::db_bootstrap = "CREATE TABLE history (vid INTEGER,"
const char * History::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
"history (vid INTEGER,"
"seq INTEGER,host_name TEXT,vm_dir TEXT,hid INTEGER,vm_mad TEXT,tm_mad TEXT,"
"stime INTEGER,etime INTEGER,pstime INTEGER,petime INTEGER,rstime INTEGER,"
"retime INTEGER,estime INTEGER,eetime INTEGER,reason INTEGER,"
"PRIMARY KEY(vid,seq))";
"PRIMARY KEY(vid,seq))";
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -85,7 +85,8 @@ const char * VirtualMachine::db_names = "(oid,uid,name,last_poll,template_id,sta
",lcm_state,stime,etime,deploy_id"
",memory,cpu,net_tx,net_rx)";
const char * VirtualMachine::db_bootstrap = "CREATE TABLE vm_pool ("
const char * VirtualMachine::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
"vm_pool ("
"oid INTEGER PRIMARY KEY,uid INTEGER,name TEXT,"
"last_poll INTEGER, template_id INTEGER,state INTEGER,lcm_state INTEGER,"
"stime INTEGER,etime INTEGER,deploy_id TEXT,memory INTEGER,cpu INTEGER,"

View File

@ -18,6 +18,6 @@
const char * VirtualMachineTemplate::table = "vm_attributes";
const char * VirtualMachineTemplate::db_bootstrap = "CREATE TABLE vm_attributes"
" (id INTEGER, name TEXT, type INTEGER, value TEXT)";
const char * VirtualMachineTemplate::db_bootstrap = "CREATE TABLE IF NOT EXISTS"
" vm_attributes (id INTEGER, name TEXT, type INTEGER, value TEXT)";

View File

@ -250,7 +250,7 @@ const char * Leases::table = "leases";
const char * Leases::db_names = "(oid,ip,mac_prefix,mac_suffix,vid,used)";
const char * Leases::db_bootstrap = "CREATE TABLE leases ("
const char * Leases::db_bootstrap = "CREATE TABLE IF NOT EXISTS leases ("
"oid INTEGER,ip BIGINT, mac_prefix INTEGER,mac_suffix INTEGER,"
"vid INTEGER, used INTEGER, PRIMARY KEY(oid,ip))";

View File

@ -53,7 +53,8 @@ const char * VirtualNetwork::table = "network_pool";
const char * VirtualNetwork::db_names = "(oid,uid,name,type,bridge)";
const char * VirtualNetwork::db_bootstrap = "CREATE TABLE network_pool ("
const char * VirtualNetwork::db_bootstrap = "CREATE TABLE IF NOT EXISTS"
" network_pool ("
"oid INTEGER PRIMARY KEY, uid INTEGER, name VARCHAR(256), type INTEGER, "
"bridge TEXT, UNIQUE(name))";

View File

@ -18,6 +18,6 @@
const char * VirtualNetworkTemplate::table = "vn_template";
const char * VirtualNetworkTemplate::db_bootstrap = "CREATE TABLE vn_template"
" (id INTEGER, name TEXT, type INTEGER, value TEXT)";
const char * VirtualNetworkTemplate::db_bootstrap = "CREATE TABLE IF NOT EXISTS"
" vn_template (id INTEGER, name TEXT, type INTEGER, value TEXT)";