Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/disposable_domain.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class DisposableDomain < ApplicationRecord
end
11 changes: 11 additions & 0 deletions db/primary_migrate/20231024170146_create_email_data_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateEmailDataTable < ActiveRecord::Migration[7.0]
def change
enable_extension "citext"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct in assuming we won't need anything additional to be installed in deployed environments for this to be enabled?


create_table :disposable_domains do |t|
t.citext :name, null: false
end

add_index :disposable_domains, :name, unique: true
end
end
8 changes: 7 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2023_08_31_124437) do
ActiveRecord::Schema[7.1].define(version: 2023_10_24_172229) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_stat_statements"
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -94,6 +95,11 @@
t.index ["user_id", "last_used_at"], name: "index_device_user_id_last_used_at"
end

create_table "disposable_domains", force: :cascade do |t|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't occur to me until now, but it would be nice to incorporate the word "email" in this name. The domains themselves aren't disposable, it's the fact that the domains offer a disposable email service.

Suggested change
create_table "disposable_domains", force: :cascade do |t|
create_table "disposable_email_domains", force: :cascade do |t|

Copy link
Contributor

@zachmargolis zachmargolis Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we don't want to deal with a table rename, we could rename the active record model and set the table name to what it is now (like we do with the Gpo models)

t.citext "name", null: false
t.index ["name"], name: "index_disposable_domains_on_name", unique: true
end

create_table "doc_auth_logs", force: :cascade do |t|
t.integer "user_id", null: false
t.datetime "welcome_view_at", precision: nil
Expand Down
11 changes: 11 additions & 0 deletions lib/tasks/disposable_domains.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# rubocop:disable Rails/SkipsModelValidations
require 'csv'
namespace :disposable_domains do
task :load, %i[s3_url] => [:environment] do |_task, args|
file = Identity::Hostdata.secrets_s3.read_file(args[:s3_url])
names = file.split("\n")
DisposableDomain.insert_all(names.map { |name| { name: } })
end
end
# rake "disposable_domains:load['URL_HERE']"
# rubocop:enable Rails/SkipsModelValidations