Merge remote-tracking branch 'origin/feature/28' into feature/28
This commit is contained in:
commit
cf1eb70748
16 changed files with 1952 additions and 14 deletions
|
|
@ -48,14 +48,14 @@ SET client_min_messages = warning;
|
|||
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
|
||||
--
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
||||
-- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
||||
--;;
|
||||
|
||||
--
|
||||
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
|
||||
--
|
||||
|
||||
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
|
||||
-- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
|
||||
--;;
|
||||
|
||||
SET search_path = public, pg_catalog;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
--------------------------------------------------------------------------------
|
||||
----
|
||||
---- 20180316110100intentions-and-options.down.sql: remove intentions and options
|
||||
----
|
||||
---- This program is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU General Public License
|
||||
---- as published by the Free Software Foundation; either version 2
|
||||
---- of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This program is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
---- GNU General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU General Public License
|
||||
---- along with this program; if not, write to the Free Software
|
||||
---- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
---- USA.
|
||||
----
|
||||
---- Copyright (C) 2016 Simon Brooke for Radical Independence Campaign
|
||||
----
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
drop table intentions;
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
--------------------------------------------------------------------------------
|
||||
----
|
||||
---- 20180316110100intentions-and-options.up.sql: add intentions and options
|
||||
----
|
||||
---- This program is free software; you can redistribute it and/or
|
||||
---- modify it under the terms of the GNU General Public License
|
||||
---- as published by the Free Software Foundation; either version 2
|
||||
---- of the License, or (at your option) any later version.
|
||||
----
|
||||
---- This program is distributed in the hope that it will be useful,
|
||||
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
---- GNU General Public License for more details.
|
||||
----
|
||||
---- You should have received a copy of the GNU General Public License
|
||||
---- along with this program; if not, write to the Free Software
|
||||
---- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
---- USA.
|
||||
----
|
||||
---- Copyright (C) 2016 Simon Brooke for Radical Independence Campaign
|
||||
----
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS intentions (
|
||||
visit_id int not null references visits(id) on delete no action,
|
||||
elector_id int not null references electors(id) on delete no action,
|
||||
option_id varchar(32) not null references options(id) on delete no action
|
||||
);
|
||||
|
||||
ALTER TABLE intentions owner to youyesyet;
|
||||
3
resources/migrations/20180317170000-gender.down.sql
Normal file
3
resources/migrations/20180317170000-gender.down.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
alter table electors drop column gender;
|
||||
|
||||
drop table genders;
|
||||
11
resources/migrations/20180317170000-gender.up.sql
Normal file
11
resources/migrations/20180317170000-gender.up.sql
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
create table genders (
|
||||
id varchar(32) not null primary key
|
||||
);
|
||||
|
||||
-- genders is reference data
|
||||
insert into genders values ('Female');
|
||||
insert into genders values ('Male');
|
||||
insert into genders values ('Non-binary');
|
||||
insert into genders values ('Unknown');
|
||||
|
||||
alter table electors add column gender varchar(32) references genders(id) default 'Unknown';
|
||||
10
resources/migrations/20180317170907-reference-data.down.sql
Normal file
10
resources/migrations/20180317170907-reference-data.down.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
delete from options where id = 'Yes';
|
||||
|
||||
delete from options where id = 'No';
|
||||
|
||||
delete from issues where id = 'Currency';
|
||||
|
||||
delete from issues where id = 'Monarchy';
|
||||
|
||||
delete from issues where id = 'Defence';
|
||||
|
||||
10
resources/migrations/20180317170907-reference-data.up.sql
Normal file
10
resources/migrations/20180317170907-reference-data.up.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
insert into options values ('Yes');
|
||||
|
||||
insert into options values ('No');
|
||||
|
||||
|
||||
insert into issues (id, url) values ('Currency', 'https://www.yyy.scot/wiki/issues/Currency');
|
||||
|
||||
insert into issues (id, url) values ('Monarchy', 'https://www.yyy.scot/wiki/issues/Monarchy');
|
||||
|
||||
insert into issues (id, url) values ('Defence', 'https://www.yyy.scot/wiki/issues/Defence');
|
||||
3
resources/migrations/20180317175047-test-data.down.sql
Normal file
3
resources/migrations/20180317175047-test-data.down.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
delete from addresses where id < = 4;
|
||||
|
||||
delete from electors where id <= 10;
|
||||
41
resources/migrations/20180317175047-test-data.up.sql
Normal file
41
resources/migrations/20180317175047-test-data.up.sql
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
insert into addresses (id, address, postcode, latitude, longitude)
|
||||
values (1, '13 Imaginary Terrace, IM1 3TE', 'IM1 3TE', 55.8253043, -4.2569057);
|
||||
|
||||
insert into addresses (id, address, postcode, latitude, longitude)
|
||||
values (2, '15 Imaginary Terrace, IM1 3TE', 'IM1 3TE', 55.8252354, -4.2572778);
|
||||
|
||||
insert into addresses (id, address, postcode, latitude, longitude)
|
||||
values (3, '17 Imaginary Terrace, IM1 3TE', 'IM1 3TE', 55.825166, -4.257026);
|
||||
|
||||
insert into addresses (id, address, postcode, latitude, longitude)
|
||||
values (4, '19 Imaginary Terrace, IM1 3TE', 'IM1 3TE', 55.8250695, -4.2570239);
|
||||
|
||||
insert into electors (id, name, address_id, gender)
|
||||
values (1, 'Alan Anderson', 1, 'Male');
|
||||
|
||||
insert into electors (id, name, address_id, gender)
|
||||
values (2, 'Ann Anderson', 1, 'Female');
|
||||
|
||||
insert into electors (id, name, address_id, gender)
|
||||
values (3, 'Alex Anderson', 1, 'Non-binary');
|
||||
|
||||
insert into electors (id, name, address_id)
|
||||
values (4, 'Andy Anderson', 1);
|
||||
|
||||
insert into electors (id, name, address_id, gender)
|
||||
values (5, 'Beryl Brown', 2, 'Female');
|
||||
|
||||
insert into electors (id, name, address_id, gender)
|
||||
values (6, 'Betty Black', 2, 'Female');
|
||||
|
||||
insert into electors (id, name, address_id, gender)
|
||||
values (7, 'Catriona Crathie', 3, 'Female');
|
||||
|
||||
insert into electors (id, name, address_id, gender)
|
||||
values (8, 'Colin Caruthers', 3, 'Male');
|
||||
|
||||
insert into electors (id, name, address_id, gender)
|
||||
values (9, 'Calum Crathie', 3, 'Unknown');
|
||||
|
||||
insert into electors (id, name, address_id, gender)
|
||||
values (10, 'David Dewar', 4, 'Male');
|
||||
Loading…
Add table
Add a link
Reference in a new issue