summaryrefslogtreecommitdiffstats
path: root/main/acf-weblog/acf-weblog.post-upgrade
blob: 18ed542fcff496f9328772f7467316dc1b7c72af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh

new=$1
old=$2

# if current is older than 0.4.0 we update.
if [ "$(apk version -t $old 0.4.0)" = "<" ]; then

psql -U postgres -c "ALTER TABLE weblog ADD COLUMN shortreason text" \
	webproxylog
psql -U postgres -c "ALTER TABLE pubweblog ADD COLUMN shortreason text" \
	webproxylog
psql -U postgres -c "ALTER TABLE pubblocklog ADD COLUMN shortreason text" \
	webproxylog  
psql -U postgres -c "ALTER TABLE blocklog ADD COLUMN shortreason text" \
	webproxylog

fi

# if current is older than 0.4.5 we update.
if [ "$(apk version -t $old 0.4.5)" = "<" ]; then

psql -U postgres -c "ALTER TABLE dbhistlog ALTER logdatetime TYPE timestamp(3)"\
	webproxylog

fi


# if current is older than 0.5.4 we update.
if [ "$(apk version -t $old 0.5.4)" = "<" ]; then

psql -U postgres -c "ALTER TABLE weblog ALTER bytes TYPE bigint"\
	webproxylog
psql -U postgres -c "ALTER TABLE pubweblog ALTER bytes TYPE bigint"\
	webproxylog
psql -U postgres -c "ALTER TABLE blocklog ALTER bytes TYPE bigint"\
	webproxylog
psql -U postgres -c "ALTER TABLE pubblocklog ALTER bytes TYPE bigint"\
	webproxylog

fi

# if current is older than 0.6.0 we update.
if [ "$(apk version -t $old 0.6.0)" = "<" ]; then

mkdir /etc/weblog
mv /etc/weblog.conf /etc/weblog/
echo "Executing db updates"
psql -U postgres -c "ALTER TABLE pubweblog ADD COLUMN badyesno int, ADD COLUMN deniedyesno int, ADD COLUMN bypassyesno int, ADD COLUMN wordloc text, ADD COLUMN goodwordloc text, ADD COLUMN selected boolean, ADD COLUMN id int UNIQUE" -d webproxylog
psql -U weblogowner -c "CREATE SEQUENCE pubweblog_id_seq" -d webproxylog
psql -U postgres -c "ALTER TABLE pubweblog ALTER COLUMN id SET DEFAULT NEXTVAL('pubweblog_id_seq')" -d webproxylog
psql -U postgres -c "UPDATE pubweblog SET id = NEXTVAL('pubweblog_id_seq')" -d webproxylog
psql -U postgres -c "INSERT INTO pubweblog SELECT *,'0','1','0','','','false' FROM pubblocklog" -d webproxylog
psql -U postgres -c "INSERT INTO pubweblog SELECT *,'0','0','0','','','false' FROM weblog" -d webproxylog
psql -U postgres -c "INSERT INTO pubweblog SELECT *,'0','1','0','','','false' FROM blocklog" -d webproxylog
psql -U postgres -c "ALTER TABLE weblog ADD COLUMN badyesno int, ADD COLUMN deniedyesno int, ADD COLUMN bypassyesno int, ADD COLUMN wordloc text, ADD COLUMN goodwordloc text" -d webproxylog
psql -U weblogowner -c "CREATE TABLE pubweblog_history(sourcename character varying(40), clientip inet NOT NULL, clientuserid character varying(64) NOT NULL, logdatetime timestamp(3) without time zone NOT NULL, uri text NOT NULL, bytes bigint NOT NULL, reason text, score integer, shortreason text, badyesno int, deniedyesno int, bypassyesno int, wordloc text, goodwordloc text, selected boolean, id int)" -d webproxylog
psql -U postgres -c "GRANT SELECT ON pubweblog_history TO webloguser" -d webproxylog
psql -U postgres -c "DROP TABLE pubblocklog" -d	webproxylog
psql -U postgres -c "DROP TABLE watchlist" -d webproxylog
psql -U postgres -c "DROP TABLE blocklog" -d webproxylog

fi

exit 0