projects
/
brisk.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
31bfc5e
)
more robust sql scripts adding IF EXISTS to DROP TABLE statementes
author
Matteo Nastasi (mop)
<nastasi@alternativeoutput.it>
Thu, 15 Oct 2015 06:28:21 +0000
(08:28 +0200)
committer
Matteo Nastasi (mop)
<nastasi@alternativeoutput.it>
Thu, 15 Oct 2015 06:28:21 +0000
(08:28 +0200)
sql/sql.d/001-struct.sql
patch
|
blob
|
history
sql/sql.d/050-bin5.sql
patch
|
blob
|
history
sql/sql.d/051-bin5-places.sql
patch
|
blob
|
history
sql/sql.d/054-continue-match.sql
patch
|
blob
|
history
sql/sql.d/060-tournament.sql
patch
|
blob
|
history
sql/sql.d/070-add-mailmgmt.sql
patch
|
blob
|
history
sql/sql.d/071-apprentice.sql
patch
|
blob
|
history
diff --git
a/sql/sql.d/001-struct.sql
b/sql/sql.d/001-struct.sql
index
302804e
..
fa1dc86
100644
(file)
--- a/
sql/sql.d/001-struct.sql
+++ b/
sql/sql.d/001-struct.sql
@@
-2,7
+2,7
@@
-- DONE - CASCADE ON DELETE of orders related tables
-- DONE - STATUS on orders
-- DONE - CASCADE ON DELETE of orders related tables
-- DONE - STATUS on orders
-DROP TABLE #PFX#users;
+DROP TABLE
IF EXISTS
#PFX#users;
CREATE TABLE #PFX#users (
code SERIAL PRIMARY KEY,
login text UNIQUE,
CREATE TABLE #PFX#users (
code SERIAL PRIMARY KEY,
login text UNIQUE,
@@
-13,7
+13,7
@@
CREATE TABLE #PFX#users (
mtime timestamp DEFAULT to_timestamp(0) -- last access
);
mtime timestamp DEFAULT to_timestamp(0) -- last access
);
-DROP TABLE #PFX#groups;
+DROP TABLE
IF EXISTS
#PFX#groups;
CREATE TABLE #PFX#groups (
code SERIAL PRIMARY KEY,
name text
CREATE TABLE #PFX#groups (
code SERIAL PRIMARY KEY,
name text
diff --git
a/sql/sql.d/050-bin5.sql
b/sql/sql.d/050-bin5.sql
index
938d5d3
..
2f58a72
100644
(file)
--- a/
sql/sql.d/050-bin5.sql
+++ b/
sql/sql.d/050-bin5.sql
@@
-2,21
+2,21
@@
-- briskin5 (bin5) related tables
--
-- briskin5 (bin5) related tables
--
-DROP TABLE #PFX#bin5_matches;
+DROP TABLE
IF EXISTS
#PFX#bin5_matches;
CREATE TABLE #PFX#bin5_matches (
code SERIAL PRIMARY KEY,
ttok text UNIQUE, -- token associated to the match
tidx integer -- table index
);
CREATE TABLE #PFX#bin5_matches (
code SERIAL PRIMARY KEY,
ttok text UNIQUE, -- token associated to the match
tidx integer -- table index
);
-DROP TABLE #PFX#bin5_games;
+DROP TABLE
IF EXISTS
#PFX#bin5_games;
CREATE TABLE #PFX#bin5_games (
code SERIAL PRIMARY KEY,
mcode integer REFERENCES #PFX#bin5_matches (code) ON DELETE cascade ON UPDATE cascade,
tstamp timestamp -- end game time
);
CREATE TABLE #PFX#bin5_games (
code SERIAL PRIMARY KEY,
mcode integer REFERENCES #PFX#bin5_matches (code) ON DELETE cascade ON UPDATE cascade,
tstamp timestamp -- end game time
);
-DROP TABLE #PFX#bin5_points;
+DROP TABLE
IF EXISTS
#PFX#bin5_points;
CREATE TABLE #PFX#bin5_points (
gcode integer REFERENCES #PFX#bin5_games (code) ON DELETE cascade ON UPDATE cascade,
ucode integer REFERENCES #PFX#users (code) ON DELETE cascade ON UPDATE cascade,
CREATE TABLE #PFX#bin5_points (
gcode integer REFERENCES #PFX#bin5_games (code) ON DELETE cascade ON UPDATE cascade,
ucode integer REFERENCES #PFX#users (code) ON DELETE cascade ON UPDATE cascade,
diff --git
a/sql/sql.d/051-bin5-places.sql
b/sql/sql.d/051-bin5-places.sql
index
ebf3add
..
6f8d7ad
100644
(file)
--- a/
sql/sql.d/051-bin5-places.sql
+++ b/
sql/sql.d/051-bin5-places.sql
@@
-6,14
+6,14
@@
-- wee = 4
--
-- wee = 4
--
-DROP
TABLE
#PFX#bin5_places_mtime;
+DROP
TABLE IF EXISTS
#PFX#bin5_places_mtime;
CREATE TABLE #PFX#bin5_places_mtime (
code int,
mtime timestamp
);
INSERT INTO #PFX#bin5_places_mtime (code, mtime) VALUES (0, now());
CREATE TABLE #PFX#bin5_places_mtime (
code int,
mtime timestamp
);
INSERT INTO #PFX#bin5_places_mtime (code, mtime) VALUES (0, now());
-DROP
TABLE
#PFX#bin5_places;
+DROP
TABLE IF EXISTS
#PFX#bin5_places;
CREATE TABLE #PFX#bin5_places (
type integer,
rank integer,
CREATE TABLE #PFX#bin5_places (
type integer,
rank integer,
diff --git
a/sql/sql.d/054-continue-match.sql
b/sql/sql.d/054-continue-match.sql
index
0ed40fb
..
e95059a
100644
(file)
--- a/
sql/sql.d/054-continue-match.sql
+++ b/
sql/sql.d/054-continue-match.sql
@@
-1,4
+1,4
@@
-DROP TABLE #PFX#bin5_table_orders;
+DROP TABLE
IF EXISTS
#PFX#bin5_table_orders;
CREATE TABLE #PFX#bin5_table_orders (
mcode integer REFERENCES #PFX#bin5_matches (code) ON DELETE cascade ON UPDATE cascade,
pos integer,
CREATE TABLE #PFX#bin5_table_orders (
mcode integer REFERENCES #PFX#bin5_matches (code) ON DELETE cascade ON UPDATE cascade,
pos integer,
diff --git
a/sql/sql.d/060-tournament.sql
b/sql/sql.d/060-tournament.sql
index
7f9e340
..
90b54a2
100644
(file)
--- a/
sql/sql.d/060-tournament.sql
+++ b/
sql/sql.d/060-tournament.sql
@@
-1,4
+1,4
@@
-DROP TABLE #PFX#bin5_tournaments;
+DROP TABLE
IF EXISTS
#PFX#bin5_tournaments;
CREATE TABLE #PFX#bin5_tournaments (
code SERIAL PRIMARY KEY,
active integer,
CREATE TABLE #PFX#bin5_tournaments (
code SERIAL PRIMARY KEY,
active integer,
diff --git
a/sql/sql.d/070-add-mailmgmt.sql
b/sql/sql.d/070-add-mailmgmt.sql
index
cef0248
..
bfd0a24
100644
(file)
--- a/
sql/sql.d/070-add-mailmgmt.sql
+++ b/
sql/sql.d/070-add-mailmgmt.sql
@@
-1,7
+1,7
@@
--
-- Table to manage mails sent to users
--
--
-- Table to manage mails sent to users
--
-DROP TABLE #PFX#mails;
+DROP TABLE
IF EXISTS
#PFX#mails;
CREATE TABLE #PFX#mails (
code SERIAL PRIMARY KEY,
ucode integer REFERENCES #PFX#users (code) ON DELETE cascade ON UPDATE cascade,
CREATE TABLE #PFX#mails (
code SERIAL PRIMARY KEY,
ucode integer REFERENCES #PFX#users (code) ON DELETE cascade ON UPDATE cascade,
diff --git
a/sql/sql.d/071-apprentice.sql
b/sql/sql.d/071-apprentice.sql
index
c3a0193
..
376427b
100644
(file)
--- a/
sql/sql.d/071-apprentice.sql
+++ b/
sql/sql.d/071-apprentice.sql
@@
-1,7
+1,7
@@
--
-- Table to manage mails sent to users
--
--
-- Table to manage mails sent to users
--
-DROP TABLE #PFX#selfreg_chk;
+DROP TABLE
IF EXISTS
#PFX#selfreg_chk;
CREATE TABLE #PFX#selfreg_chk (
ip integer, -- ip v4 address
atime timestamp DEFAULT to_timestamp(0) -- access time
CREATE TABLE #PFX#selfreg_chk (
ip integer, -- ip v4 address
atime timestamp DEFAULT to_timestamp(0) -- access time