Skip to content

Commit

Permalink
Merge pull request #1474 from quintel/Qi-DB
Browse files Browse the repository at this point in the history
Migration to add the include_in_qi_db attribute on the Users table
  • Loading branch information
louispt1 authored Nov 25, 2024
2 parents fcbb744 + 24ad71a commit deaee7e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions db/migrate/20241125104913_add_qi_field_on_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class AddQiFieldOnUser < ActiveRecord::Migration[7.0]

DOMAINS = [
'@quintel.com',
'@energytransitionmodel.com',
'@tennet.eu',
'@netbeheernederland.nl',
'@gasunie.nl',
'@kalavasta.com',
'@entsog.eu',
'@sec.entsoe.eu',
'@economy-bi.gov.uk',
'@nijmegen.nl',
'@rotterdam.nl',
'@tudelft.nl',
'@alliander.com',
'@noord-holland.nl'
].freeze

def up
add_column :users, :include_in_qi_db, :boolean, default: false

User.where(DOMAINS.map { |domain| "email LIKE ?" }.join(' OR '), *DOMAINS.map { |domain| "%#{domain}" })
.update_all(include_in_qi_db: true)
end

def down
remove_column :users, :include_in_qi_db
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_11_12_093940) do
ActiveRecord::Schema[7.0].define(version: 2024_11_25_104913) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "name", limit: 191, null: false
t.string "record_type", limit: 191, null: false
Expand Down Expand Up @@ -251,6 +251,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "deleted_at"
t.boolean "include_in_qi_db", default: false
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
Expand Down

0 comments on commit deaee7e

Please sign in to comment.