diff options
-rw-r--r-- | db/schema.sql | 3 | ||||
-rw-r--r-- | db/schema_0001-add_sessions_and_users_and_dbic_fields.sql | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Abuse.pm | 5 |
3 files changed, 11 insertions, 4 deletions
diff --git a/db/schema.sql b/db/schema.sql index 297a13946..86a9598c4 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -358,9 +358,8 @@ create table flickr_imported ( create unique index flickr_imported_id_idx on flickr_imported(id); create table abuse ( - email text not null + email text primary key check( lower(email) = email ) ); -create unique index abuse_email_idx on abuse(lower(email)); create table textmystreet ( name text not null, diff --git a/db/schema_0001-add_sessions_and_users_and_dbic_fields.sql b/db/schema_0001-add_sessions_and_users_and_dbic_fields.sql index 992f3c685..581741fe8 100644 --- a/db/schema_0001-add_sessions_and_users_and_dbic_fields.sql +++ b/db/schema_0001-add_sessions_and_users_and_dbic_fields.sql @@ -44,4 +44,11 @@ create or replace function contacts_updated() end; ' language 'plpgsql'; + +--- add pk and lowercase check to abuse +drop index abuse_email_idx; +update abuse set email = lower(email); +alter table abuse add check( lower(email) = email ); +alter table abuse add primary key(email); + commit; diff --git a/perllib/FixMyStreet/DB/Result/Abuse.pm b/perllib/FixMyStreet/DB/Result/Abuse.pm index 55b22d433..c83e6ef70 100644 --- a/perllib/FixMyStreet/DB/Result/Abuse.pm +++ b/perllib/FixMyStreet/DB/Result/Abuse.pm @@ -11,9 +11,10 @@ use base 'DBIx::Class::Core'; __PACKAGE__->load_components("FilterColumn"); __PACKAGE__->table("abuse"); __PACKAGE__->add_columns( "email", { data_type => "text", is_nullable => 0 } ); +__PACKAGE__->set_primary_key("email"); -# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-03-28 12:14:16 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fCIpGt51z5iDH9LmHeuRYQ +# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-04-15 12:11:26 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:J3vO9UpeoxI19WPRmEaI0w # You can replace this text with custom code or comments, and it will be preserved on regeneration 1; |