-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade.sh
executable file
·106 lines (80 loc) · 3.02 KB
/
upgrade.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
set -o errexit
cd `dirname $0`
eval `./admin/ShowDBDefs`
echo `date` : Upgrading to RELEASE-20081123-BRANCH
# Drop the old replication triggers on the master, so that the changes in 20080201-1.sql don't create
# massive replication packets.
if [ "$REPLICATION_TYPE" = "$RT_MASTER" ]
then
echo `date` : Drop replication triggers
./admin/psql READWRITE < ./admin/sql/DropReplicationTriggers.sql
fi
echo `date` : Update script, language and country tables
./admin/psql READWRITE < ./admin/sql/updates/20081115-1.sql
echo `date` : Adding CD Stub support
./admin/psql RAWDATA < ./admin/sql/updates/20071212-1.sql
echo `date` : Adding AR improvements
./admin/psql READWRITE < ./admin/sql/updates/20080201-1.sql
echo `date` : 'Drop TRMs!'
./admin/psql READWRITE < ./admin/sql/updates/20080529.sql
echo `date` : Add meta tables
./admin/psql READWRITE < ./admin/sql/updates/20080610-1.sql
if [ "$REPLICATION_TYPE" != "$RT_SLAVE" ]
then
# constraints
./admin/psql READWRITE < ./admin/sql/updates/20080610-2.sql
fi
echo `date` : Add ratings support to database
./admin/psql READWRITE < ./admin/sql/updates/20080707-1.sql
./admin/psql RAWDATA < ./admin/sql/updates/20080707-2.sql
echo `date` : Add collection support to database
./admin/psql RAWDATA < ./admin/sql/updates/20080711-1.sql
echo `date` : Add dateadded, fix moderation and track fields type
./admin/psql READWRITE < ./admin/sql/updates/20080729.sql
if [ "$REPLICATION_TYPE" != "$RT_SLAVE" ]
then
echo `date` : Populating albummeta.dateadded
./admin/sql/updates/PopulateAlbumDateAdded.pl
fi
echo `date` : Add tags relation support to database
./admin/psql READWRITE < ./admin/sql/updates/20081017-1.sql
if [ "$REPLICATION_TYPE" != "$RT_SLAVE" ]
then
# constraints
./admin/psql READWRITE < ./admin/sql/updates/20081017-2.sql
fi
if [ "$REPLICATION_TYPE" != "$RT_SLAVE" ]
then
echo `date` : Generate new stats from past moderations and votes
./admin/psql READWRITE < ./admin/sql/updates/20081027.sql
fi
# Drop the functions and triggers in order to fix the one wrong PUID update function
echo `date` : Re loading functions
if [ "$REPLICATION_TYPE" != "$RT_SLAVE" ]
then
./admin/psql READWRITE < ./admin/sql/DropTriggers.sql
fi
./admin/psql READWRITE < ./admin/sql/DropFunctions.sql
./admin/psql READWRITE < ./admin/sql/CreateFunctions.sql
if [ "$REPLICATION_TYPE" != "$RT_SLAVE" ]
then
./admin/psql READWRITE < ./admin/sql/CreateTriggers.sql
fi
if [ "$REPLICATION_TYPE" = "$RT_MASTER" ]
then
echo `date` : Create replication triggers
./admin/psql READWRITE < ./admin/sql/CreateReplicationTriggers.sql
fi
echo `date` : Going to schema sequence $DB_SCHEMA_SEQUENCE
echo "UPDATE replication_control SET current_schema_sequence = $DB_SCHEMA_SEQUENCE;" | ./admin/psql READWRITE
# We're now at the new schema, so the next replication packet (if we are
# the master) will have the new SCHEMA_SEQUENCE number; thus, it can only
# be applied to a new schema.
if [ "$REPLICATION_TYPE" != "$RT_SLAVE" ]
then
./admin/cleanup/ModPending.pl
./admin/cleanup/UpdateCoverArt.pl
fi
echo `date` : Done
# eof