Skip to content

Commit

Permalink
Merge pull request #1684 from tactilenews/fix-seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwr18 authored Aug 9, 2023
2 parents c0b4c12 + d6ffc8d commit 4c2ef5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@
t.datetime "additional_consent_given_at"
t.bigint "organization_id"
t.string "whats_app_phone_number"
t.datetime "whats_app_message_template_responded_at"
t.bigint "deactivated_by_user_id"
t.boolean "deactivated_by_admin", default: false
t.datetime "whats_app_message_template_responded_at"
t.datetime "whats_app_message_template_sent_at"
t.index ["email"], name: "index_contributors_on_email", unique: true
t.index ["organization_id"], name: "index_contributors_on_organization_id"
Expand Down
27 changes: 20 additions & 7 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,26 @@
password = ENV.fetch('SEED_USER_PASSWORD', SecureRandom.alphanumeric(20))
otp_secret_key = ENV.fetch('SEED_USER_OTP_SECRET', User.otp_random_secret)

organization = Organization.create_or_find_by(name: '100eyes',
upgrade_discount: 10,
business_plan: BusinessPlan.first)
admin = User.create_or_find_by(email: 'redaktion@tactile.news', first_name: 'Dennis', last_name: 'Schröder', password: password,
admin: true, otp_secret_key: otp_secret_key)
user = User.create_or_find_by(email: 'contact-person@example_organization.org', first_name: 'ConactFor', last_name: 'Organization',
password: password, otp_secret_key: otp_secret_key, organization: organization)
business_plan = BusinessPlan.create!(
name: 'Free',
price_per_month: 0,
setup_cost: 0,
hours_of_included_support: 0,
number_of_users: 5,
number_of_contributors: 150,
number_of_communities: 1,
valid_from: Time.current,
valid_until: Time.current + 6.months
)
organization = Organization.create_or_find_by!(
name: '100eyes',
upgrade_discount: 10,
business_plan: business_plan
)
admin = User.create_or_find_by!(email: 'redaktion@tactile.news', first_name: 'Dennis', last_name: 'Schröder', password: password,
admin: true, otp_secret_key: otp_secret_key)
user = User.create_or_find_by!(email: 'contact-person@example-organization.org', first_name: 'ConactFor', last_name: 'Organization',
password: password, otp_secret_key: otp_secret_key, organization: organization)
organization.update(contact_person: user)
puts "Organization with name #{organization.name}"
puts "Admin with email #{admin.email}"
Expand Down

0 comments on commit 4c2ef5c

Please sign in to comment.