diff options
author | floppydiskette <floppydisk@hyprcat.net> | 2024-09-13 12:58:12 +0100 |
---|---|---|
committer | floppydiskette <floppydisk@hyprcat.net> | 2024-09-13 12:59:16 +0100 |
commit | 2c3400fb4f5a22951d42f286975201bf817d7883 (patch) | |
tree | a08b06f5f6d5df4f6774da7645d85418609a4cf2 /tasks/db/seed/sample_data.cr | |
parent | d8915dcca4d9752f6f254e86afa39ef7f83617d1 (diff) |
wronglucky
Diffstat (limited to 'tasks/db/seed/sample_data.cr')
-rw-r--r-- | tasks/db/seed/sample_data.cr | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tasks/db/seed/sample_data.cr b/tasks/db/seed/sample_data.cr new file mode 100644 index 0000000..231d7e8 --- /dev/null +++ b/tasks/db/seed/sample_data.cr @@ -0,0 +1,30 @@ +require "../../../spec/support/factories/**" + +# Add sample data helpful for development, e.g. (fake users, blog posts, etc.) +# +# Use `Db::Seed::RequiredData` if you need to create data *required* for your +# app to work. +class Db::Seed::SampleData < LuckyTask::Task + summary "Add sample database records helpful for development" + + def call + # Using an Avram::Factory: + # + # Use the defaults, but override just the email + # UserFactory.create &.email("me@example.com") + + # Using a SaveOperation: + # ``` + # SignUpUser.create!(email: "me@example.com", password: "test123", password_confirmation: "test123") + # ``` + # + # 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: + # ``` + # if UserQuery.new.email("me@example.com").none? + # SignUpUser.create!(email: "me@example.com", password: "test123", password_confirmation: "test123") + # end + # ``` + puts "Done adding sample data" + end +end |