diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/040_email_is_unique.rb | 19 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/db/migrate/040_email_is_unique.rb b/db/migrate/040_email_is_unique.rb new file mode 100644 index 000000000..fa4bf529a --- /dev/null +++ b/db/migrate/040_email_is_unique.rb @@ -0,0 +1,19 @@ +class EmailIsUnique < ActiveRecord::Migration + def self.up + execute "create unique index users_email_index on users (lower(email))" + + # Don't need these any more, with new special url_name fields + execute 'drop index users_url_name_index' + execute 'drop index public_bodies_url_short_name_index' + execute 'drop index public_body_versions_url_short_name_index' + + end + + def self.down + execute "drop unique index users_email_index" + + execute "create index public_bodies_url_short_name_index on public_bodies(regexp_replace(replace(lower(short_name), ' ', '-'), '[^a-z0-9_-]', '', 'g'))" + execute "create index public_body_versions_url_short_name_index on public_body_versions(regexp_replace(replace(lower(short_name), ' ', '-'), '[^a-z0-9_-]', '', 'g'))" + execute "create index users_url_name_index on users (regexp_replace(replace(lower(name), ' ', '-'), '[^a-z0-9_-]', '', 'g'))" + end +end diff --git a/db/schema.rb b/db/schema.rb index 0e8c26f80..58ddb696d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 39) do +ActiveRecord::Schema.define(:version => 40) do create_table "incoming_messages", :force => true do |t| t.integer "info_request_id", :null => false |