Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from elRatto21/create_models
Browse files Browse the repository at this point in the history
create basic models
  • Loading branch information
elRatto21 authored Sep 20, 2024
2 parents 084f798 + fe6b552 commit eb76c26
Show file tree
Hide file tree
Showing 23 changed files with 280 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/bike.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Bike < ApplicationRecord
belongs_to :team
end
5 changes: 5 additions & 0 deletions app/models/part.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Part < ApplicationRecord
has_and_belongs_to_many :services
belongs_to :bike
belongs_to :team
end
4 changes: 4 additions & 0 deletions app/models/service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Service < ApplicationRecord
has_and_belongs_to_many :parts
belongs_to :bike
end
2 changes: 2 additions & 0 deletions app/models/team.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Team < ApplicationRecord
end
3 changes: 3 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class User < ApplicationRecord
belongs_to :team
end
9 changes: 9 additions & 0 deletions db/migrate/20240920065435_create_teams.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateTeams < ActiveRecord::Migration[7.2]
def change
create_table :teams do |t|
t.string :name

t.timestamps
end
end
end
13 changes: 13 additions & 0 deletions db/migrate/20240920065635_create_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CreateUsers < ActiveRecord::Migration[7.2]
def change
create_table :users do |t|
t.string :email
t.string :name
t.string :password
t.string :role
t.references :team, null: false, foreign_key: true

t.timestamps
end
end
end
15 changes: 15 additions & 0 deletions db/migrate/20240920065722_create_bikes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class CreateBikes < ActiveRecord::Migration[7.2]
def change
create_table :bikes do |t|
t.string :manufacturer
t.string :model
t.integer :horsepower
t.integer :weight
t.integer :year
t.integer :mileage
t.references :team, null: false, foreign_key: true

t.timestamps
end
end
end
12 changes: 12 additions & 0 deletions db/migrate/20240920070510_create_services.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateServices < ActiveRecord::Migration[7.2]
def change
create_table :services do |t|
t.string :title
t.text :description
t.references :bike, null: false, foreign_key: true
t.date :date

t.timestamps
end
end
end
14 changes: 14 additions & 0 deletions db/migrate/20240920070827_create_parts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CreateParts < ActiveRecord::Migration[7.2]
def change
create_table :parts do |t|
t.string :title
t.text :description
t.float :price
t.date :date
t.references :bike, null: false, foreign_key: true
t.references :team, null: false, foreign_key: true

t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions db/migrate/20240920070917_create_jointable_services_parts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateJointableServicesParts < ActiveRecord::Migration[7.2]
def change
create_table :jointable_services_parts do |t|
t.string :service
t.string :part

t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeBikeIdToBeOptionalInParts < ActiveRecord::Migration[7.2]
def change
change_column_null :parts, :bike_id, true
end
end
79 changes: 79 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions test/fixtures/bikes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
manufacturer: MyString
model: MyString
horsepower: 1
weight: 1
year: 1
mileage: 1
team: one

two:
manufacturer: MyString
model: MyString
horsepower: 1
weight: 1
year: 1
mileage: 1
team: two
17 changes: 17 additions & 0 deletions test/fixtures/parts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
title: MyString
description: MyText
price: 1.5
date: 2024-09-20
bike: one
team: one

two:
title: MyString
description: MyText
price: 1.5
date: 2024-09-20
bike: two
team: two
13 changes: 13 additions & 0 deletions test/fixtures/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
title: MyString
description: MyText
bike: one
date: 2024-09-20

two:
title: MyString
description: MyText
bike: two
date: 2024-09-20
7 changes: 7 additions & 0 deletions test/fixtures/teams.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
name: MyString

two:
name: MyString
15 changes: 15 additions & 0 deletions test/fixtures/users.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
email: MyString
name: MyString
password: MyString
role: MyString
team: one

two:
email: MyString
name: MyString
password: MyString
role: MyString
team: two
7 changes: 7 additions & 0 deletions test/models/bike_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class BikeTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
7 changes: 7 additions & 0 deletions test/models/part_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class PartTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
7 changes: 7 additions & 0 deletions test/models/service_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class ServiceTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
7 changes: 7 additions & 0 deletions test/models/team_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class TeamTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
7 changes: 7 additions & 0 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit eb76c26

Please sign in to comment.