run migration to create database

parent 3a90ec44
Pipeline #1342 canceled with stages
in 0 seconds
...@@ -7,7 +7,7 @@ ruby '3.0.1' ...@@ -7,7 +7,7 @@ ruby '3.0.1'
gem 'rails', '~> 6.1.3', '>= 6.1.3.2' gem 'rails', '~> 6.1.3', '>= 6.1.3.2'
gem 'bootstrap', '~> 5.0.1' gem 'bootstrap', '~> 5.0.1'
# Use sqlite3 as the database for Active Record # Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4' gem 'mysql2', '~> 0.5.3'
# Use Puma as the app server # Use Puma as the app server
gem 'puma', '~> 5.0' gem 'puma', '~> 5.0'
# Use SCSS for stylesheets # Use SCSS for stylesheets
......
...@@ -106,6 +106,7 @@ GEM ...@@ -106,6 +106,7 @@ GEM
mini_mime (1.1.0) mini_mime (1.1.0)
minitest (5.14.4) minitest (5.14.4)
msgpack (1.4.2) msgpack (1.4.2)
mysql2 (0.5.3)
nio4r (2.5.7) nio4r (2.5.7)
nokogiri (1.11.7-x86_64-linux) nokogiri (1.11.7-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
...@@ -147,7 +148,7 @@ GEM ...@@ -147,7 +148,7 @@ GEM
method_source method_source
rake (>= 0.13) rake (>= 0.13)
thor (~> 1.0) thor (~> 1.0)
rake (13.0.3) rake (13.0.4)
rb-fsevent (0.11.0) rb-fsevent (0.11.0)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
...@@ -175,7 +176,6 @@ GEM ...@@ -175,7 +176,6 @@ GEM
actionpack (>= 4.0) actionpack (>= 4.0)
activesupport (>= 4.0) activesupport (>= 4.0)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
sqlite3 (1.4.2)
thor (1.1.0) thor (1.1.0)
tilt (2.0.10) tilt (2.0.10)
turbolinks (5.2.1) turbolinks (5.2.1)
...@@ -214,13 +214,13 @@ DEPENDENCIES ...@@ -214,13 +214,13 @@ DEPENDENCIES
capybara (>= 3.26) capybara (>= 3.26)
jbuilder (~> 2.7) jbuilder (~> 2.7)
listen (~> 3.3) listen (~> 3.3)
mysql2 (~> 0.5.3)
puma (~> 5.0) puma (~> 5.0)
rack-mini-profiler (~> 2.0) rack-mini-profiler (~> 2.0)
rails (~> 6.1.3, >= 6.1.3.2) rails (~> 6.1.3, >= 6.1.3.2)
sass-rails (>= 6) sass-rails (>= 6)
selenium-webdriver selenium-webdriver
spring spring
sqlite3 (~> 1.4)
turbolinks (~> 5) turbolinks (~> 5)
tzinfo-data tzinfo-data
web-console (>= 4.1.0) web-console (>= 4.1.0)
......
class AppliesJob < ApplicationRecord
belongs_to :user
belongs_to :job
end
class City < ApplicationRecord
has_and_belongs_to_many :jobs
has_many :regions
end
class Company < ApplicationRecord
has_and_belongs_to_many :cities
end
class Industry < ApplicationRecord
end
class Job < ApplicationRecord
has_and_belongs_to_many :users
has_many :applies_jobs
has_many :users, through: :applies_jobs
end
class Region < ApplicationRecord
belongs_to :city
end
class User < ApplicationRecord
has_and_belongs_to_many :jobs
has_many :applies_jobs
has_many :jobs, through: :applies_jobs
end
...@@ -5,21 +5,25 @@ ...@@ -5,21 +5,25 @@
# gem 'sqlite3' # gem 'sqlite3'
# #
default: &default default: &default
adapter: sqlite3 adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000 timeout: 5000
username: root
password: lalili1005
socket: /var/run/mysqld/mysqld.sock
development: development:
<<: *default <<: *default
database: db/development.sqlite3 database: VeNJOB_development
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test:
<<: *default <<: *default
database: db/test.sqlite3 database: VeNJOB_test
production: production:
<<: *default <<: *default
database: db/production.sqlite3 database: VeNJOB_production
class CreateJobs < ActiveRecord::Migration[6.1]
def change
create_table :jobs do |t|
t.string :title
t.text :overview
t.text :requirement
t.text :other_requirement
t.integer :salary
t.string :type
t.string :level
t.integer :experience
t.string :benefits
t.string :degree
t.datetime :expired_at
t.timestamps
end
end
end
class CreateUsers < ActiveRecord::Migration[6.1]
def change
create_table :users do |t|
t.string :name
t.string :email
t.binary :cv
t.timestamps
end
end
end
class CreateIndustries < ActiveRecord::Migration[6.1]
def change
create_table :industries do |t|
t.string :name
t.timestamps
end
end
end
class CreateCities < ActiveRecord::Migration[6.1]
def change
create_table :cities do |t|
t.string :name
t.string :address
t.timestamps
end
end
end
class CreateCompanies < ActiveRecord::Migration[6.1]
def change
create_table :companies do |t|
t.string :name
t.text :description
t.integer :total_employee
t.string :type
t.string :benefits
t.text :message
t.timestamps
end
end
end
class CreateFavouritesJobs < ActiveRecord::Migration[6.1]
def change
create_table :favourites_jobs do |t|
t.references :user, null: false, foreign_key: true
t.references :job, null: false, foreign_key: true
t.timestamps
end
end
end
class CreateHistorisJobs < ActiveRecord::Migration[6.1]
def change
create_table :historis_jobs do |t|
t.references :user, null: false, foreign_key: true
t.references :job, null: false, foreign_key: true
t.timestamps
end
end
end
class CreateIndustriesJobs < ActiveRecord::Migration[6.1]
def change
create_table :industries_jobs do |t|
t.references :job, null: false, foreign_key: true
t.references :industry, null: false, foreign_key: true
t.timestamps
end
end
end
class CreateCitiesJobs < ActiveRecord::Migration[6.1]
def change
create_table :cities_jobs do |t|
t.references :job, null: false, foreign_key: true
t.references :city, null: false, foreign_key: true
t.timestamps
end
end
end
class CreateCitiesCompanies < ActiveRecord::Migration[6.1]
def change
create_table :cities_companies do |t|
t.references :company, null: false, foreign_key: true
t.references :city, null: false, foreign_key: true
t.timestamps
end
end
end
class CreateAppliesJobs < ActiveRecord::Migration[6.1]
def change
create_table :applies_jobs do |t|
t.references :user, null: false, foreign_key: true
t.references :job, null: false, foreign_key: true
t.binary :cv
t.timestamps
end
end
end
class CreateRegions < ActiveRecord::Migration[6.1]
def change
create_table :regions do |t|
t.references :city, null: false, foreign_key: true
t.string :name
t.timestamps
end
end
end
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_07_08_034910) do
create_table "applies_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "job_id", null: false
t.binary "cv"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["job_id"], name: "index_applies_jobs_on_job_id"
t.index ["user_id"], name: "index_applies_jobs_on_user_id"
end
create_table "cities", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name"
t.string "address"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "cities_companies", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "company_id", null: false
t.bigint "city_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["city_id"], name: "index_cities_companies_on_city_id"
t.index ["company_id"], name: "index_cities_companies_on_company_id"
end
create_table "cities_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "job_id", null: false
t.bigint "city_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["city_id"], name: "index_cities_jobs_on_city_id"
t.index ["job_id"], name: "index_cities_jobs_on_job_id"
end
create_table "companies", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name"
t.text "description"
t.integer "total_employee"
t.string "type"
t.string "benefits"
t.text "message"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "favourites_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "job_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["job_id"], name: "index_favourites_jobs_on_job_id"
t.index ["user_id"], name: "index_favourites_jobs_on_user_id"
end
create_table "historis_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "job_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["job_id"], name: "index_historis_jobs_on_job_id"
t.index ["user_id"], name: "index_historis_jobs_on_user_id"
end
create_table "industries", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "industries_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "job_id", null: false
t.bigint "industry_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["industry_id"], name: "index_industries_jobs_on_industry_id"
t.index ["job_id"], name: "index_industries_jobs_on_job_id"
end
create_table "jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "title"
t.text "overview"
t.text "requirement"
t.text "other_requirement"
t.integer "salary"
t.string "type"
t.string "level"
t.integer "experience"
t.string "benefits"
t.string "degree"
t.datetime "expired_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "regions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "city_id", null: false
t.string "name"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["city_id"], name: "index_regions_on_city_id"
end
create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name"
t.string "email"
t.binary "cv"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
add_foreign_key "applies_jobs", "jobs"
add_foreign_key "applies_jobs", "users"
add_foreign_key "cities_companies", "cities"
add_foreign_key "cities_companies", "companies"
add_foreign_key "cities_jobs", "cities"
add_foreign_key "cities_jobs", "jobs"
add_foreign_key "favourites_jobs", "jobs"
add_foreign_key "favourites_jobs", "users"
add_foreign_key "historis_jobs", "jobs"
add_foreign_key "historis_jobs", "users"
add_foreign_key "industries_jobs", "industries"
add_foreign_key "industries_jobs", "jobs"
add_foreign_key "regions", "cities"
end
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
user: one
job: one
cv:
two:
user: two
job: two
cv:
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
city: one
name: MyString
two:
city: two
name: MyString
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
require "test_helper"
class AppliesJobTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require "test_helper"
class CityTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require "test_helper"
class CompanyTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require "test_helper"
class IndustryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require "test_helper"
class JobTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require "test_helper"
class RegionTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require "test_helper"
class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment