67 lines
3.2 KiB
Ruby
67 lines
3.2 KiB
Ruby
# This file should ensure the existence of records required to run the application in every environment (production,
|
|
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
|
|
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
|
#
|
|
# Example:
|
|
#
|
|
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
|
|
# MovieGenre.find_or_create_by!(name: genre_name)
|
|
# end
|
|
puts "Bereinige Datenbank..."
|
|
AssignmentLog.destroy_all
|
|
Item.destroy_all
|
|
Room.destroy_all
|
|
User.destroy_all
|
|
Department.destroy_all
|
|
Category.destroy_all
|
|
|
|
puts "Erstelle Abteilungen..."
|
|
dept_mit = Department.create!(name: "Mitarbeiter", code: "Mit")
|
|
dept_prof = Department.create!(name: "Professor", code: "Prof")
|
|
dept_wimi = Department.create!(name: "Wissenschaftlicher Mitarbeiter", code: "WiMi")
|
|
Department.create!(name: "Studentische Hilfskraft", code: "HiWi")
|
|
|
|
puts "Erstelle Benutzer..."
|
|
u1 = User.create!(first_name: "Max", last_name: "Mustermann", email: "max@firma.de", password: "password123123", department: dept_mit)
|
|
u2 = User.create!(first_name: "Julia", last_name: "Herhold", email: "julia.herhold@hs-rm.de", password: "password123123", department: dept_prof)
|
|
|
|
User.create!(first_name: "Silke", last_name: "Bartsch", email: "silke.bartsch@hs-rm.de", password: "password123123", department: dept_mit)
|
|
User.create!(first_name: "Mario", last_name: "Miscioscia", email: "mario.miscioschia@hs-rm.de", password: "password123123", department: dept_wimi)
|
|
|
|
puts "Erstelle Kategorien..."
|
|
cat_hardware = Category.create!(name: "Hardware", description: "Laptops und Monitore")
|
|
cat_furniture = Category.create!(name: "Möbel", description: "Tische und Stühle")
|
|
|
|
puts "Erstelle Räume..."
|
|
room_101 = Room.create!(name: "D101", building: "D", floor: "EG")
|
|
room_102 = Room.create!(name: "D102", building: "D", floor: "EG")
|
|
[ "D103", "D106", "D107", "D116", "D118", "D121", "D122", "D123", "D124", "D125", "D126", "D127", "D128", "D131", "D132" ].each { |rnr| Room.create!(name: rnr, building: "D", floor: "EG") }
|
|
[ "D201", "D202" ].each { |rnr| Room.create!(name: rnr, building: "D", floor: "1. OG") }
|
|
[ "D302", "D303" ].each { |rnr| Room.create!(name: rnr, building: "D", floor: "2. OG") }
|
|
room_lab = Room.create!(name: "D301", building: "D", floor: "2.OG")
|
|
|
|
puts "Erstelle Artikel..."
|
|
# Artikel fest an User vergeben
|
|
item_laptop = Item.create!(
|
|
name: "MacBook Pro 16\"", sku: "MBP16-M3", sticker_id: "10001", serial_number: "C02F1234XYZ",
|
|
price: 2500.00, notes: "Entwickler-Laptop", category: cat_hardware, user: u1
|
|
)
|
|
|
|
# Artikel fest an einen Raum vergeben
|
|
item_monitor = Item.create!(
|
|
name: "Dell 27\" Monitor", sku: "DELL-U27", sticker_id: "10002", serial_number: "CN-0708XX",
|
|
price: 450.00, notes: nil, category: cat_hardware, room: room_101
|
|
)
|
|
|
|
Item.create!(
|
|
name: "Dell 27\" Monitor", sku: "DELL-U27", sticker_id: "10003", serial_number: "CN-0748XD",
|
|
price: 450.00, notes: nil, category: cat_hardware, room: room_102
|
|
)
|
|
|
|
Item.create!(
|
|
name: "Dell 27\" Monitor", sku: "DELL-U27", sticker_id: "10004", serial_number: "CN-0728DD",
|
|
price: 450.00, notes: nil, category: cat_hardware, room: room_102
|
|
)
|
|
|
|
puts "🎉 Datenbank erfolgreich aufgesetzt!"
|