-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1662 from geeksforsocialchange/ik-1480-db-seeding
Begin improving seeds
- Loading branch information
Showing
11 changed files
with
74 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,14 +25,10 @@ FileUtils.chdir APP_ROOT do | |
|
||
puts "\n== Preparing database ==" | ||
system! 'bin/rails db:prepare' | ||
system! 'bin/rails seed:migrate' | ||
|
||
puts "\n== Importing events ==" | ||
system! 'bin/rails import:all_events' | ||
|
||
puts "\n== Creating admin user ==" | ||
system! 'bin/rails runner \'User.where(email: "[email protected]").exists? || User.create!(email: "[email protected]", password: "password", password_confirmation: "password", role: :root)\'' | ||
|
||
puts "\n== Removing old logs and tempfiles ==" | ||
system! 'bin/rails log:clear tmp:clear' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
# This file is auto-generated from the current content of the database. Instead | ||
# of editing this file, please use the migrations feature of Seed Migration to | ||
# incrementally modify your database, and then regenerate this seed file. | ||
# This file should contain all the record creation needed to seed the database with its default values. | ||
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). | ||
# | ||
# If you need to create the database on another system, you should be using | ||
# db:seed, not running all the migrations from scratch. The latter is a flawed | ||
# and unsustainable approach (the more migrations you'll amass, the slower | ||
# it'll run and the greater likelihood for issues). | ||
# Examples: | ||
# | ||
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) | ||
# Character.create(name: 'Luke', movie: movies.first) | ||
# | ||
# It's strongly recommended to check this file into your version control system. | ||
|
||
ActiveRecord::Base.transaction do | ||
Dir[Rails.root.join('db/seeds/*.rb')].sort.each do |file| | ||
Rails.logger.debug { "Seeding from #{file.split('/').slice(-3, 3).join('/')}" } | ||
require file | ||
end | ||
|
||
SeedMigration::Migrator.bootstrap(20_180_625_172_033) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module UserSeeder | ||
module_function | ||
|
||
def run | ||
user = User.find_or_create_by!(email: '[email protected]') do |u| | ||
u.password = 'password' | ||
u.password_confirmation = 'password' | ||
u.role = :root | ||
end | ||
|
||
user.invite! | ||
user.accept_invitation! | ||
end | ||
end | ||
|
||
UserSeeder.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
Site.find_or_create_by!( | ||
slug: 'default-site' | ||
) do |site| | ||
site.name = 'Normal Island' | ||
site.domain = "#{site.slug}.lvh.me" | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters