29 lines
881 B
Crystal
29 lines
881 B
Crystal
require "../spec/support/boxes/**"
|
|
|
|
# Add sample data helpful for development, e.g. (fake users, blog posts, etc.)
|
|
#
|
|
# Use `Db::CreateRequiredSeeds` if you need to create data *required* for your
|
|
# app to work.
|
|
class Db::CreateSampleSeeds < LuckyCli::Task
|
|
summary "Add sample database records helpful for development"
|
|
|
|
def call
|
|
# Using a Avram::Box:
|
|
#
|
|
# Use the defaults, but override just the email
|
|
# UserBox.create &.email("me@example.com")
|
|
|
|
# Using a SaveOperation:
|
|
#
|
|
# SaveUser.create!(email: "me@example.com", name: "Jane")
|
|
#
|
|
# You likely want to be able to run this file more than once. To do that,
|
|
# only create the record if it doesn't exist yet:
|
|
#
|
|
# unless UserQuery.new.email("me@example.com").first?
|
|
# SaveUser.create!(email: "me@example.com", name: "Jane")
|
|
# end
|
|
puts "Done adding sample data"
|
|
end
|
|
end
|