Added some models
User Item Department Categorie AssignmentLog Room
This commit is contained in:
10
db/migrate/20260521120102_create_categories.rb
Normal file
10
db/migrate/20260521120102_create_categories.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateCategories < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :categories do |t|
|
||||
t.string :name
|
||||
t.text :description
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
10
db/migrate/20260521121137_create_departments.rb
Normal file
10
db/migrate/20260521121137_create_departments.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateDepartments < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :departments do |t|
|
||||
t.string :name
|
||||
t.string :code
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
19
db/migrate/20260521124041_create_items.rb
Normal file
19
db/migrate/20260521124041_create_items.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class CreateItems < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :items do |t|
|
||||
t.string :name
|
||||
t.string :sku
|
||||
t.string :sticker_id
|
||||
t.string :serial_number
|
||||
t.decimal :price, precision: 8, scale: 2
|
||||
t.text :notes
|
||||
t.references :category, foreign_key: true
|
||||
t.references :user, foreign_key: true
|
||||
t.references :room, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :items, :sticker_id, unique: true
|
||||
add_index :items, :serial_number, unique: true
|
||||
end
|
||||
end
|
||||
13
db/migrate/20260521124606_create_assignment_logs.rb
Normal file
13
db/migrate/20260521124606_create_assignment_logs.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateAssignmentLogs < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :assignment_logs do |t|
|
||||
t.references :item, foreign_key: true
|
||||
t.references :user, foreign_key: true
|
||||
t.references :room, foreign_key: true
|
||||
t.datetime :assigned_at
|
||||
t.datetime :returned_at
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
9
db/migrate/20260521124755_add_details_to_users.rb
Normal file
9
db/migrate/20260521124755_add_details_to_users.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class AddDetailsToUsers < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_column :users, :first_name, :string
|
||||
add_column :users, :last_name, :string
|
||||
|
||||
# WICHTIG: null: true erlaubt es, dass alte User erst einmal ohne Abteilung migriert werden
|
||||
add_reference :users, :department, null: true, foreign_key: true
|
||||
end
|
||||
end
|
||||
11
db/migrate/20260521125254_create_rooms.rb
Normal file
11
db/migrate/20260521125254_create_rooms.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateRooms < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :rooms do |t|
|
||||
t.string :name
|
||||
t.string :building
|
||||
t.string :floor
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user