Commit 6a2e0164 by Thanh Hung Pham

Merge branch 'database' into 'master'

run migration to create database

See merge request !1
parents 3a90ec44 0cf394d3
Pipeline #1349 failed 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 ApplyJob < ApplicationRecord
belongs_to :user
belongs_to :job
end
class City < ApplicationRecord
belongs_to :region
has_and_belongs_to_many :jobs
has_and_belongs_to_many :companies
end
class Company < ApplicationRecord
has_many :jobs
has_and_belongs_to_many :cities
end
class FavoriteJob < ApplicationRecord
belongs_to :user
belongs_to :job
end
class HistoryJob < ApplicationRecord
belongs_to :user
belongs_to :job
end
class Industry < ApplicationRecord
has_and_belongs_to_many :jobs
end
class Job < ApplicationRecord
belongs_to :company
has_many :apply_jobs
has_many :favorite_jobs
has_many :history_jobs
has_and_belongs_to_many :industries
has_and_belongs_to_many :cities
end
class Region < ApplicationRecord
has_many :cities
end
class User < ApplicationRecord
has_many :apply_jobs
has_many :favorite_jobs
has_many :history_jobs
end
...@@ -5,21 +5,18 @@ ...@@ -5,21 +5,18 @@
# 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
socket: /var/run/mysqld/mysqld.sock
development: development:
<<: *default <<: *default
database: db/development.sqlite3 username: root
password: lalili1005
# Warning: The database defined as "test" will be erased and database: VeNJOB_development
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production: production:
<<: *default <<: *default
database: db/production.sqlite3 database: VeNJOB_production
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 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 CreateIndustries < ActiveRecord::Migration[6.1]
def change
create_table :industries do |t|
t.string :name
t.timestamps
end
end
end
class CreateRegions < ActiveRecord::Migration[6.1]
def change
create_table :regions do |t|
t.string :name
t.timestamps
end
end
end
class CreateCities < ActiveRecord::Migration[6.1]
def change
create_table :cities do |t|
t.references :region, null: false, foreign_key: true
t.string :name
t.string :address
t.timestamps
end
end
end
class CreateCompaniesCities < ActiveRecord::Migration[6.1]
def change
create_table :companies_cities do |t|
t.references :company, null: false, foreign_key: true
t.references :city, null: false, foreign_key: true
t.timestamps
end
end
end
class CreateJobs < ActiveRecord::Migration[6.1]
def change
create_table :jobs do |t|
t.references :company, null: false, foreign_key: true
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 :degree
t.string :benefits
t.datetime :expired_at
t.timestamps
end
end
end
class CreateApplyJobs < ActiveRecord::Migration[6.1]
def change
create_table :apply_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 CreateFavoriteJobs < ActiveRecord::Migration[6.1]
def change
create_table :favorite_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 CreateHistoryJobs < ActiveRecord::Migration[6.1]
def change
create_table :history_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 CreateCitiesJobs < ActiveRecord::Migration[6.1]
def change
create_table :cities_jobs do |t|
t.references :city, 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 :industry, null: false, foreign_key: true
t.references :job, null: false, foreign_key: true
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_09_043354) do
create_table "apply_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_apply_jobs_on_job_id"
t.index ["user_id"], name: "index_apply_jobs_on_user_id"
end
create_table "cities", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "region_id", null: false
t.string "name"
t.string "address"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["region_id"], name: "index_cities_on_region_id"
end
create_table "cities_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "city_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 ["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 "companies_cities", 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_companies_cities_on_city_id"
t.index ["company_id"], name: "index_companies_cities_on_company_id"
end
create_table "favorite_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_favorite_jobs_on_job_id"
t.index ["user_id"], name: "index_favorite_jobs_on_user_id"
end
create_table "history_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_history_jobs_on_job_id"
t.index ["user_id"], name: "index_history_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 "industry_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 ["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.bigint "company_id", null: false
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 "degree"
t.string "benefits"
t.datetime "expired_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["company_id"], name: "index_jobs_on_company_id"
end
create_table "regions", 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 "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 "apply_jobs", "jobs"
add_foreign_key "apply_jobs", "users"
add_foreign_key "cities", "regions"
add_foreign_key "cities_jobs", "cities"
add_foreign_key "cities_jobs", "jobs"
add_foreign_key "companies_cities", "cities"
add_foreign_key "companies_cities", "companies"
add_foreign_key "favorite_jobs", "jobs"
add_foreign_key "favorite_jobs", "users"
add_foreign_key "history_jobs", "jobs"
add_foreign_key "history_jobs", "users"
add_foreign_key "industries_jobs", "industries"
add_foreign_key "industries_jobs", "jobs"
add_foreign_key "jobs", "companies"
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