Skip to content

Commit eb76c26

Browse files
authored
Merge pull request #1 from elRatto21/create_models
create basic models
2 parents 084f798 + fe6b552 commit eb76c26

23 files changed

+280
-0
lines changed

app/models/bike.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Bike < ApplicationRecord
2+
belongs_to :team
3+
end

app/models/part.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Part < ApplicationRecord
2+
has_and_belongs_to_many :services
3+
belongs_to :bike
4+
belongs_to :team
5+
end

app/models/service.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Service < ApplicationRecord
2+
has_and_belongs_to_many :parts
3+
belongs_to :bike
4+
end

app/models/team.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Team < ApplicationRecord
2+
end

app/models/user.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class User < ApplicationRecord
2+
belongs_to :team
3+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class CreateTeams < ActiveRecord::Migration[7.2]
2+
def change
3+
create_table :teams do |t|
4+
t.string :name
5+
6+
t.timestamps
7+
end
8+
end
9+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class CreateUsers < ActiveRecord::Migration[7.2]
2+
def change
3+
create_table :users do |t|
4+
t.string :email
5+
t.string :name
6+
t.string :password
7+
t.string :role
8+
t.references :team, null: false, foreign_key: true
9+
10+
t.timestamps
11+
end
12+
end
13+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class CreateBikes < ActiveRecord::Migration[7.2]
2+
def change
3+
create_table :bikes do |t|
4+
t.string :manufacturer
5+
t.string :model
6+
t.integer :horsepower
7+
t.integer :weight
8+
t.integer :year
9+
t.integer :mileage
10+
t.references :team, null: false, foreign_key: true
11+
12+
t.timestamps
13+
end
14+
end
15+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class CreateServices < ActiveRecord::Migration[7.2]
2+
def change
3+
create_table :services do |t|
4+
t.string :title
5+
t.text :description
6+
t.references :bike, null: false, foreign_key: true
7+
t.date :date
8+
9+
t.timestamps
10+
end
11+
end
12+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class CreateParts < ActiveRecord::Migration[7.2]
2+
def change
3+
create_table :parts do |t|
4+
t.string :title
5+
t.text :description
6+
t.float :price
7+
t.date :date
8+
t.references :bike, null: false, foreign_key: true
9+
t.references :team, null: false, foreign_key: true
10+
11+
t.timestamps
12+
end
13+
end
14+
end

0 commit comments

Comments
 (0)