instructeurs: create without providing the email

This commit is contained in:
Pierre de La Morinerie 2019-10-16 12:15:47 +00:00
parent f131dbb80d
commit f8358b3ae9
7 changed files with 22 additions and 15 deletions

View file

@ -0,0 +1,13 @@
class RemoveUniqueConstraintOnInstructeurEmails < ActiveRecord::Migration[5.2]
def up
# Drop the index entirely
remove_index :instructeurs, :email
# Add the index again, without the unicity constraint
add_index :instructeurs, :email
end
def down
remove_index :instructeurs, :email
add_index :instructeurs, :email, unique: true
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_10_23_183120) do
ActiveRecord::Schema.define(version: 2019_10_24_150452) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -419,7 +419,7 @@ ActiveRecord::Schema.define(version: 2019_10_23_183120) do
t.datetime "updated_at"
t.text "encrypted_login_token"
t.datetime "login_token_created_at"
t.index ["email"], name: "index_instructeurs_on_email", unique: true
t.index ["email"], name: "index_instructeurs_on_email"
end
create_table "invites", id: :serial, force: :cascade do |t|

View file

@ -10,12 +10,10 @@ default_password = "this is a very complicated password !"
puts "Create test user '#{default_user}'"
Administration.create!(email: default_user, password: default_password)
administrateur = Administrateur.create!(email: default_user)
instructeur = Instructeur.create!(email: default_user)
User.create!(
user = User.create!(
email: default_user,
password: default_password,
confirmed_at: Time.zone.now,
administrateur: administrateur,
instructeur: instructeur
confirmed_at: Time.zone.now
)
user.create_instructeur!
user.create_administrateur!(email: user.email)