phase002 complete
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
class CreateUsers < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :users do |t|
|
||||
t.string :name, null: false
|
||||
t.string :email, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :users, "lower(email)", unique: true, name: "index_users_on_lower_email"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
class CreateVehicles < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :vehicles do |t|
|
||||
t.string :make, null: false
|
||||
t.string :model, null: false
|
||||
t.integer :year, null: false
|
||||
t.string :color, null: false
|
||||
t.string :vin, null: false
|
||||
t.string :licence_plate, null: false
|
||||
t.integer :current_odometer, null: false
|
||||
t.decimal :fuel_tank_size, precision: 8, scale: 2, null: false
|
||||
t.boolean :active, null: false, default: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :vehicles, :vin, unique: true
|
||||
add_index :vehicles, "lower(licence_plate)", unique: true, name: "index_vehicles_on_lower_licence_plate"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
class CreateMaintenanceSchedules < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :maintenance_schedules do |t|
|
||||
t.references :vehicle, null: false, foreign_key: true
|
||||
t.string :maintenance_type, null: false
|
||||
t.integer :mileage_interval, null: false
|
||||
t.integer :time_interval, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :maintenance_schedules,
|
||||
"vehicle_id, lower(maintenance_type)",
|
||||
unique: true,
|
||||
name: "index_maintenance_schedules_on_vehicle_and_lower_type"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class CreateFuelEntries < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :fuel_entries do |t|
|
||||
t.references :vehicle, null: false, foreign_key: true
|
||||
t.references :updated_by_user, null: false, foreign_key: { to_table: :users }
|
||||
t.integer :odometer, null: false
|
||||
t.decimal :gallons_pumped, precision: 8, scale: 2, null: false
|
||||
t.decimal :price_paid, precision: 10, scale: 2, null: false
|
||||
t.date :date, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class CreateMaintenanceEntries < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :maintenance_entries do |t|
|
||||
t.references :vehicle, null: false, foreign_key: true
|
||||
t.references :updated_by_user, null: false, foreign_key: { to_table: :users }
|
||||
t.string :name, null: false
|
||||
t.text :notes, null: false
|
||||
t.integer :odometer, null: false
|
||||
t.decimal :cost, precision: 10, scale: 2, null: false
|
||||
t.date :date, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user