diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-20 12:34:02 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-20 12:34:02 +0100 |
commit | 5ff2cb6203e950f08d33e457da8d3d3875283b40 (patch) | |
tree | 327e0dfa45fc27e4bfa4f428aca484aa96d43aa5 | |
parent | b994038f7d169ac6a3bf270c8a371fa7d285e4b2 (diff) | |
parent | 983ddaff992ba81091360e718c107ab66299cd2d (diff) |
Merge branch 'migrate_to_catalyst' of ssh://git.mysociety.org/data/git/public/fixmystreet into migrate_to_catalyst
-rwxr-xr-x | db/rerun_dbic_loader.pl | 5 | ||||
-rw-r--r-- | db/schema.sql | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Questionnaire.pm | 48 |
5 files changed, 67 insertions, 12 deletions
diff --git a/db/rerun_dbic_loader.pl b/db/rerun_dbic_loader.pl index a21fea301..7c38fae58 100755 --- a/db/rerun_dbic_loader.pl +++ b/db/rerun_dbic_loader.pl @@ -3,7 +3,7 @@ use strict; use warnings; -# This script inspects the current state of the database and then ammends the +# This script inspects the current state of the database and then amends the # FixMyStreet::DB::Result::* files to suit. After running the changes should be # inspected before the code is commited. @@ -20,7 +20,6 @@ my @tables_to_ignore = ( 'debugdate', # 'flickr_imported', # 'partial_user', # - 'questionnaire', # 'secret', # 'textmystreet', # ); @@ -30,7 +29,7 @@ make_schema_at( 'FixMyStreet::DB', { debug => 0, # switch on to be chatty - dump_directory => './lib', # edit files in place + dump_directory => './perllib', # edit files in place exclude => qr{$exclude}, # ignore some tables generate_pod => 0, # no need for pod overwrite_modifications => 1, # don't worry that the md5 is wrong diff --git a/db/schema.sql b/db/schema.sql index 86a9598c4..9c5b3d8fd 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -262,8 +262,9 @@ create function problem_find_nearby(double precision, double precision, double p create table comment ( id serial not null primary key, problem_id integer not null references problem(id), + user_id int references users(id) not null, + anonymous bool not null, name text, -- null means anonymous - email text not null, website text, created timestamp not null default ms_current_timestamp(), confirmed timestamp, @@ -283,6 +284,7 @@ create table comment ( -- and should be highlighted in the display? ); +create index comment_user_id_idx on comment(user_id); create index comment_problem_id_idx on comment(problem_id); create index comment_problem_id_created_idx on comment(problem_id, created); @@ -318,7 +320,7 @@ create table alert ( alert_type text not null references alert_type(ref), parameter text, -- e.g. Problem ID for new updates, Longitude for local problem alerts parameter2 text, -- e.g. Latitude for local problem alerts - email text not null, + user_id int references users(id) not null, confirmed integer not null default 0, lang text not null default 'en-gb', cobrand text not null default '' check (cobrand ~* '^[a-z0-9]*$'), @@ -326,11 +328,11 @@ create table alert ( whensubscribed timestamp not null default ms_current_timestamp(), whendisabled timestamp default null ); -create index alert_email_idx on alert(email); +create index alert_user_id_idx on alert ( user_id ); create index alert_alert_type_confirmed_whendisabled_idx on alert(alert_type, confirmed, whendisabled); create index alert_whendisabled_cobrand_idx on alert(whendisabled, cobrand); create index alert_whensubscribed_confirmed_cobrand_idx on alert(whensubscribed, confirmed, cobrand); --- Possible indexes - unique (alert_type,email,parameter) +-- Possible indexes - unique (alert_type,user_id,parameter) create table alert_sent ( alert_id integer not null references alert(id), diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 73c5876d6..53337c6e7 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -51,7 +51,7 @@ __PACKAGE__->add_columns( "user_id", { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "anonymous", - { data_type => "boolean", is_nullable => 1 }, + { data_type => "boolean", is_nullable => 0 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to( @@ -68,8 +68,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-18 11:45:22 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1HsEtlhxEN6I/umfbrswSw +# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-20 12:11:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3w16OBO6ExapfttNqJzjpA # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index d91e8c324..0dc673f23 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -92,10 +92,16 @@ __PACKAGE__->belongs_to( { id => "user_id" }, { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); +__PACKAGE__->has_many( + "questionnaires", + "FixMyStreet::DB::Result::Questionnaire", + { "foreign.problem_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); -# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-17 14:18:03 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LyIl4gkdC2Lo2vuddrEByQ +# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-20 12:11:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qY08aYo4JBAg/aVmf/IzqQ =head2 check_for_errors diff --git a/perllib/FixMyStreet/DB/Result/Questionnaire.pm b/perllib/FixMyStreet/DB/Result/Questionnaire.pm new file mode 100644 index 000000000..db569e838 --- /dev/null +++ b/perllib/FixMyStreet/DB/Result/Questionnaire.pm @@ -0,0 +1,48 @@ +package FixMyStreet::DB::Result::Questionnaire; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +__PACKAGE__->load_components("FilterColumn"); +__PACKAGE__->table("questionnaire"); +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, + sequence => "questionnaire_id_seq", + }, + "problem_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "whensent", + { data_type => "timestamp", is_nullable => 0 }, + "whenanswered", + { data_type => "timestamp", is_nullable => 1 }, + "ever_reported", + { data_type => "boolean", is_nullable => 1 }, + "old_state", + { data_type => "text", is_nullable => 1 }, + "new_state", + { data_type => "text", is_nullable => 1 }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->belongs_to( + "problem", + "FixMyStreet::DB::Result::Problem", + { id => "problem_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-05-20 12:11:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6CunhdbfTFdNnjhurkV0Gg + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; |