diff options
Diffstat (limited to 'tasks/db/seed/required_data.cr')
-rw-r--r-- | tasks/db/seed/required_data.cr | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tasks/db/seed/required_data.cr b/tasks/db/seed/required_data.cr new file mode 100644 index 0000000..d866040 --- /dev/null +++ b/tasks/db/seed/required_data.cr @@ -0,0 +1,30 @@ +require "../../../spec/support/factories/**" + +# Add seeds here that are *required* for your app to work. +# For example, you might need at least one admin user or you might need at least +# one category for your blog posts for the app to work. +# +# Use `Db::Seed::SampleData` if your only want to add sample data helpful for +# development. +class Db::Seed::RequiredData < LuckyTask::Task + summary "Add database records required for the app to work" + + def call + # Using a Avram::Factory: + # + # Use the defaults, but override just the email + # UserFactory.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 required data" + end +end |