comparison flys-backend/ChangeLog @ 2349:775e316f255b

units table: Added update statements for existing databases flys-backend/trunk@2890 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 05 Oct 2011 09:03:58 +0000
parents 8477965674ce
children 3eb520b7a70e
comparison
equal deleted inserted replaced
2348:8477965674ce 2349:775e316f255b
1 2011-10-05 Sascha L. Teichmann <sascha.teichmann@intevation.de>:
2
3 * ChangeLog: Added database update statements.
4
5 To update existing databases:
6
7 BEGIN;
8 CREATE SEQUENCE UNITS_ID_SEQ;
9 CREATE TABLE units (
10 id int PRIMARY KEY NOT NULL,
11 name VARCHAR(32) NOT NULL UNIQUE
12 );
13 ALTER TABLE rivers ADD COLUMN wst_unit_id int REFERENCES units(id);
14 INSERT INTO units (id, name) VALUES (nextval('UNITS_ID_SEQ'), 'NN + m');
15 INSERT INTO units (id, name) VALUES (nextval('UNITS_ID_SEQ'), 'NHN + m');
16 UPDATE rivers SET wst_unit_id = (SELECT id FROM units WHERE name = 'NHN + m') WHERE name = 'Elbe';
17 UPDATE rivers SET wst_unit_id = (SELECT id FROM units WHERE name = 'NN + m') WHERE name <> 'Elbe';
18 ALTER TABLE rivers ALTER COLUMN wst_unit_id SET NOT NULL;
19 COMMIT;
20
1 2011-10-05 Ingo Weinzierl <ingo@intevation.de> 21 2011-10-05 Ingo Weinzierl <ingo@intevation.de>
2 22
3 * contrib/dump-schema.sh: New. A small shell script that dumps the 23 * contrib/dump-schema.sh: New. A small shell script that dumps the
4 database schema of a given database to SQL. 24 database schema of a given database to SQL.
5 25

http://dive4elements.wald.intevation.org