Added some models
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

User
Item
Department
Categorie
AssignmentLog
Room
This commit is contained in:
2026-05-21 15:36:23 +02:00
parent 7b02520b6c
commit b7f0c35378
27 changed files with 387 additions and 2 deletions

View 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

View 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

View 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

View 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

View 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

View 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