-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,42 @@ | ||
# db/seeds.rb | ||
|
||
# Clear old data | ||
puts "Cleaning up old data" | ||
Card.destroy_all | ||
KanbanColumn.destroy_all | ||
Kanban.destroy_all | ||
User.destroy_all # Remove this line if you don't want to reset the User | ||
ActiveRecord::Base.transaction do | ||
# Create default user | ||
puts "Creating or finding user" | ||
default_user = User.find_or_create_by!(email: '[email protected]') do |user| | ||
user.password = 'Password01' | ||
user.password_confirmation = 'Password01' | ||
user.username = 'loftwah' | ||
user.first_name = 'Dean' | ||
user.last_name = 'Lofts' | ||
user.short_description = 'DevOps Engineer, Proompter and a big fan of Open Source.' | ||
user.tags = 'AWS,DevOps,GitHub,Open Source,Ruby,Ruby on Rails' | ||
end | ||
|
||
# Create default user | ||
puts "Creating user" | ||
default_user = User.create!( | ||
email: '[email protected]', | ||
password: 'Password01', | ||
password_confirmation: 'Password01', | ||
username: 'loftwah', | ||
first_name: 'Dean', | ||
last_name: 'Lofts', | ||
short_description: 'DevOps Engineer, Proompter and a big fan of Open Source.', | ||
tags: 'AWS,DevOps,GitHub,Open Source,Ruby,Ruby on Rails' | ||
) | ||
# Create Kanban Board | ||
puts "Creating or finding demo Kanban Board" | ||
demo_kanban = Kanban.find_or_create_by!(name: 'Linkarooie Project', user_id: default_user.id) do |kanban| | ||
kanban.description = 'This is a demo board for Linkarooie application.' | ||
end | ||
|
||
# Create Kanban Board | ||
puts "Creating demo Kanban Board" | ||
demo_kanban = Kanban.create!( | ||
name: 'Linkarooie Project', | ||
description: 'This is a demo board for Linkarooie application.', | ||
user_id: default_user.id | ||
) | ||
# Create Kanban Columns and Cards | ||
puts "Creating or updating Kanban Columns and Cards" | ||
['Backlog', 'In Progress', 'Completed'].each do |col_name| | ||
column = demo_kanban.kanban_columns.find_or_create_by!(name: col_name) | ||
|
||
# Create Kanban Columns and Cards | ||
puts "Creating Kanban Columns and Cards" | ||
['Backlog', 'In Progress', 'Completed'].each do |col_name| | ||
column = demo_kanban.kanban_columns.create!(name: col_name) | ||
|
||
case col_name | ||
when 'Backlog' | ||
tasks = [ | ||
'Set up the initial Rails project', | ||
'Create Models and Migrations', | ||
'Install Devise for User Authentication' | ||
] | ||
when 'In Progress' | ||
tasks = [ | ||
'Develop CRUD operations for Links', | ||
'Implement AWS S3 Storage' | ||
] | ||
when 'Completed' | ||
tasks = [ | ||
'Initial Project Setup', | ||
'Setup GitHub Actions for CI/CD' | ||
] | ||
end | ||
tasks = case col_name | ||
when 'Backlog' | ||
['Set up the initial Rails project', 'Create Models and Migrations', 'Install Devise for User Authentication'] | ||
when 'In Progress' | ||
['Develop CRUD operations for Links', 'Implement AWS S3 Storage'] | ||
when 'Completed' | ||
['Initial Project Setup', 'Setup GitHub Actions for CI/CD'] | ||
end | ||
|
||
tasks.each_with_index do |task, index| | ||
column.cards.create!(content: task) | ||
tasks.each_with_index do |task, _index| | ||
column.cards.find_or_create_by!(content: task) | ||
end | ||
end | ||
end | ||
|
||
puts "Seeding complete." | ||
puts "Seeding complete." | ||
end |