diff --git a/app/models/employer.rb b/app/models/employer.rb new file mode 100644 index 0000000..91bccd1 --- /dev/null +++ b/app/models/employer.rb @@ -0,0 +1,6 @@ +class Employer < ApplicationRecord + has_many :participants + has_many :workers, through: :participants + # Association with Vendor if needed + end + \ No newline at end of file diff --git a/app/models/participant.rb b/app/models/participant.rb new file mode 100644 index 0000000..170711c --- /dev/null +++ b/app/models/participant.rb @@ -0,0 +1,5 @@ +class Participant < ApplicationRecord + belongs_to :employer + has_and_belongs_to_many :programs + has_many :workers +end diff --git a/app/models/program.rb b/app/models/program.rb new file mode 100644 index 0000000..28f20e5 --- /dev/null +++ b/app/models/program.rb @@ -0,0 +1,4 @@ +class Program < ApplicationRecord + has_and_belongs_to_many :participants + end + \ No newline at end of file diff --git a/app/models/vendor.rb b/app/models/vendor.rb new file mode 100644 index 0000000..4248275 --- /dev/null +++ b/app/models/vendor.rb @@ -0,0 +1,5 @@ +class Vendor < ApplicationRecord + # Many-to-many relationships + has_and_belongs_to_many :participants + has_and_belongs_to_many :employers +end diff --git a/app/models/worker.rb b/app/models/worker.rb new file mode 100644 index 0000000..de3f1cb --- /dev/null +++ b/app/models/worker.rb @@ -0,0 +1,7 @@ +class Worker < ApplicationRecord + # One-to-many relationship with Participants + has_many :participants + + # Many-to-many relationship with Employers through Participants + has_many :employers, through: :participants +end diff --git a/db/migrate/20240117023456_create_participants.rb b/db/migrate/20240117023456_create_participants.rb new file mode 100644 index 0000000..c34ed69 --- /dev/null +++ b/db/migrate/20240117023456_create_participants.rb @@ -0,0 +1,17 @@ +class CreateParticipants < ActiveRecord::Migration[7.1] + def change + create_table :participants do |t| + t.string :name + t.string :address + t.string :phone + t.string :email + t.string :mci + t.date :dob + t.string :ssn + t.string :gender + t.references :employer, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20240117023520_create_employers.rb b/db/migrate/20240117023520_create_employers.rb new file mode 100644 index 0000000..eb59d4a --- /dev/null +++ b/db/migrate/20240117023520_create_employers.rb @@ -0,0 +1,16 @@ +class CreateEmployers < ActiveRecord::Migration[7.1] + def change + create_table :employers do |t| + t.string :name + t.string :address + t.string :phone + t.string :email + t.string :tin + t.date :dob + t.string :ssn + t.string :gender + + t.timestamps + end + end +end diff --git a/db/migrate/20240117023541_create_workers.rb b/db/migrate/20240117023541_create_workers.rb new file mode 100644 index 0000000..214b75c --- /dev/null +++ b/db/migrate/20240117023541_create_workers.rb @@ -0,0 +1,15 @@ +class CreateWorkers < ActiveRecord::Migration[7.1] + def change + create_table :workers do |t| + t.string :name + t.string :address + t.string :phone + t.string :email + t.date :dob + t.string :ssn + t.string :gender + + t.timestamps + end + end +end diff --git a/db/migrate/20240117023553_create_vendors.rb b/db/migrate/20240117023553_create_vendors.rb new file mode 100644 index 0000000..6434690 --- /dev/null +++ b/db/migrate/20240117023553_create_vendors.rb @@ -0,0 +1,15 @@ +class CreateVendors < ActiveRecord::Migration[7.1] + def change + create_table :vendors do |t| + t.string :name + t.string :address + t.string :phone + t.string :email + t.string :dba + t.string :tin + t.string :contact_name + + t.timestamps + end + end +end diff --git a/db/migrate/20240117023614_create_programs.rb b/db/migrate/20240117023614_create_programs.rb new file mode 100644 index 0000000..99f8362 --- /dev/null +++ b/db/migrate/20240117023614_create_programs.rb @@ -0,0 +1,9 @@ +class CreatePrograms < ActiveRecord::Migration[7.1] + def change + create_table :programs do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20240117024001_create_join_table_participant_program.rb b/db/migrate/20240117024001_create_join_table_participant_program.rb new file mode 100644 index 0000000..e99d224 --- /dev/null +++ b/db/migrate/20240117024001_create_join_table_participant_program.rb @@ -0,0 +1,8 @@ +class CreateJoinTableParticipantProgram < ActiveRecord::Migration[7.1] + def change + create_join_table :participants, :programs do |t| + # t.index [:participant_id, :program_id] + # t.index [:program_id, :participant_id] + end + end +end diff --git a/db/migrate/20240117025000_add_worker_to_participants.rb b/db/migrate/20240117025000_add_worker_to_participants.rb new file mode 100644 index 0000000..fb99d8f --- /dev/null +++ b/db/migrate/20240117025000_add_worker_to_participants.rb @@ -0,0 +1,5 @@ +class AddWorkerToParticipants < ActiveRecord::Migration[7.1] + def change + add_reference :participants, :worker, null: false, foreign_key: true + end +end diff --git a/db/migrate/20240117025150_create_join_table_vendor_participant.rb b/db/migrate/20240117025150_create_join_table_vendor_participant.rb new file mode 100644 index 0000000..c995b32 --- /dev/null +++ b/db/migrate/20240117025150_create_join_table_vendor_participant.rb @@ -0,0 +1,8 @@ +class CreateJoinTableVendorParticipant < ActiveRecord::Migration[7.1] + def change + create_join_table :vendors, :participants do |t| + # t.index [:vendor_id, :participant_id] + # t.index [:participant_id, :vendor_id] + end + end +end diff --git a/db/migrate/20240117025159_create_join_table_vendor_employer.rb b/db/migrate/20240117025159_create_join_table_vendor_employer.rb new file mode 100644 index 0000000..fc87a26 --- /dev/null +++ b/db/migrate/20240117025159_create_join_table_vendor_employer.rb @@ -0,0 +1,8 @@ +class CreateJoinTableVendorEmployer < ActiveRecord::Migration[7.1] + def change + create_join_table :vendors, :employers do |t| + # t.index [:vendor_id, :employer_id] + # t.index [:employer_id, :vendor_id] + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8caab49..76a6169 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,58 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_01_15_041321) do +ActiveRecord::Schema[7.1].define(version: 2024_01_17_025159) do + create_table "employers", force: :cascade do |t| + t.string "name" + t.string "address" + t.string "phone" + t.string "email" + t.string "tin" + t.date "dob" + t.string "ssn" + t.string "gender" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "employers_vendors", id: false, force: :cascade do |t| + t.integer "vendor_id", null: false + t.integer "employer_id", null: false + end + + create_table "participants", force: :cascade do |t| + t.string "name" + t.string "address" + t.string "phone" + t.string "email" + t.string "mci" + t.date "dob" + t.string "ssn" + t.string "gender" + t.integer "employer_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "worker_id", null: false + t.index ["employer_id"], name: "index_participants_on_employer_id" + t.index ["worker_id"], name: "index_participants_on_worker_id" + end + + create_table "participants_programs", id: false, force: :cascade do |t| + t.integer "participant_id", null: false + t.integer "program_id", null: false + end + + create_table "participants_vendors", id: false, force: :cascade do |t| + t.integer "vendor_id", null: false + t.integer "participant_id", null: false + end + + create_table "programs", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false @@ -23,4 +74,30 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_15_041321) do t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end + create_table "vendors", force: :cascade do |t| + t.string "name" + t.string "address" + t.string "phone" + t.string "email" + t.string "dba" + t.string "tin" + t.string "contact_name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "workers", force: :cascade do |t| + t.string "name" + t.string "address" + t.string "phone" + t.string "email" + t.date "dob" + t.string "ssn" + t.string "gender" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_foreign_key "participants", "employers" + add_foreign_key "participants", "workers" end diff --git a/test/fixtures/employers.yml b/test/fixtures/employers.yml new file mode 100644 index 0000000..bfea014 --- /dev/null +++ b/test/fixtures/employers.yml @@ -0,0 +1,21 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + address: MyString + phone: MyString + email: MyString + tin: MyString + dob: 2024-01-16 + ssn: MyString + gender: MyString + +two: + name: MyString + address: MyString + phone: MyString + email: MyString + tin: MyString + dob: 2024-01-16 + ssn: MyString + gender: MyString diff --git a/test/fixtures/participants.yml b/test/fixtures/participants.yml new file mode 100644 index 0000000..b224169 --- /dev/null +++ b/test/fixtures/participants.yml @@ -0,0 +1,23 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + address: MyString + phone: MyString + email: MyString + mci: MyString + dob: 2024-01-16 + ssn: MyString + gender: MyString + employer: one + +two: + name: MyString + address: MyString + phone: MyString + email: MyString + mci: MyString + dob: 2024-01-16 + ssn: MyString + gender: MyString + employer: two diff --git a/test/fixtures/programs.yml b/test/fixtures/programs.yml new file mode 100644 index 0000000..7d41224 --- /dev/null +++ b/test/fixtures/programs.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + +two: + name: MyString diff --git a/test/fixtures/vendors.yml b/test/fixtures/vendors.yml new file mode 100644 index 0000000..9561496 --- /dev/null +++ b/test/fixtures/vendors.yml @@ -0,0 +1,19 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + address: MyString + phone: MyString + email: MyString + dba: MyString + tin: MyString + contact_name: MyString + +two: + name: MyString + address: MyString + phone: MyString + email: MyString + dba: MyString + tin: MyString + contact_name: MyString diff --git a/test/fixtures/workers.yml b/test/fixtures/workers.yml new file mode 100644 index 0000000..a2ec394 --- /dev/null +++ b/test/fixtures/workers.yml @@ -0,0 +1,19 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + address: MyString + phone: MyString + email: MyString + dob: 2024-01-16 + ssn: MyString + gender: MyString + +two: + name: MyString + address: MyString + phone: MyString + email: MyString + dob: 2024-01-16 + ssn: MyString + gender: MyString diff --git a/test/models/employer_test.rb b/test/models/employer_test.rb new file mode 100644 index 0000000..4255064 --- /dev/null +++ b/test/models/employer_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class EmployerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/participant_test.rb b/test/models/participant_test.rb new file mode 100644 index 0000000..82da5d0 --- /dev/null +++ b/test/models/participant_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class ParticipantTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/program_test.rb b/test/models/program_test.rb new file mode 100644 index 0000000..1658794 --- /dev/null +++ b/test/models/program_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class ProgramTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/vendor_test.rb b/test/models/vendor_test.rb new file mode 100644 index 0000000..449f613 --- /dev/null +++ b/test/models/vendor_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class VendorTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/worker_test.rb b/test/models/worker_test.rb new file mode 100644 index 0000000..2ceed9b --- /dev/null +++ b/test/models/worker_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class WorkerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end