Commit 459a3629 by Trịnh Hoàng Phúc

Merge branch 'feature/rake_task_crawler' into 'master'

Migrate database, rake task crawler

See merge request !1
parents 9281ef78 36ba17f0
Pipeline #543 failed with stages
in 0 seconds
...@@ -6,7 +6,8 @@ ruby '2.7.0' ...@@ -6,7 +6,8 @@ ruby '2.7.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2', '>= 6.0.2.2' gem 'rails', '~> 6.0.2', '>= 6.0.2.2'
# Use sqlite3 as the database for Active Record # Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4' # gem 'sqlite3', '~> 1.4'
gem 'mysql2'
# Use Puma as the app server # Use Puma as the app server
gem 'puma', '~> 4.1' gem 'puma', '~> 4.1'
# Use SCSS for stylesheets # Use SCSS for stylesheets
......
...@@ -61,6 +61,8 @@ GEM ...@@ -61,6 +61,8 @@ GEM
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.4.6) bootsnap (1.4.6)
msgpack (~> 1.0) msgpack (~> 1.0)
bootsnap (1.4.6-java)
msgpack (~> 1.0)
builder (3.2.4) builder (3.2.4)
byebug (11.1.1) byebug (11.1.1)
capybara (3.32.0) capybara (3.32.0)
...@@ -76,6 +78,9 @@ GEM ...@@ -76,6 +78,9 @@ GEM
crass (1.0.6) crass (1.0.6)
erubi (1.9.0) erubi (1.9.0)
ffi (1.12.2) ffi (1.12.2)
ffi (1.12.2-java)
ffi (1.12.2-x64-mingw32)
ffi (1.12.2-x86-mingw32)
globalid (0.4.2) globalid (0.4.2)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
i18n (1.8.2) i18n (1.8.2)
...@@ -99,12 +104,27 @@ GEM ...@@ -99,12 +104,27 @@ GEM
mini_portile2 (2.4.0) mini_portile2 (2.4.0)
minitest (5.14.0) minitest (5.14.0)
msgpack (1.3.3) msgpack (1.3.3)
msgpack (1.3.3-java)
msgpack (1.3.3-x64-mingw32)
msgpack (1.3.3-x86-mingw32)
mysql2 (0.5.3)
mysql2 (0.5.3-x64-mingw32)
mysql2 (0.5.3-x86-mingw32)
mysql2 (0.5.3-x86-mswin32-60)
nio4r (2.5.2) nio4r (2.5.2)
nio4r (2.5.2-java)
nokogiri (1.10.9) nokogiri (1.10.9)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
nokogiri (1.10.9-java)
nokogiri (1.10.9-x64-mingw32)
mini_portile2 (~> 2.4.0)
nokogiri (1.10.9-x86-mingw32)
mini_portile2 (~> 2.4.0)
public_suffix (4.0.3) public_suffix (4.0.3)
puma (4.3.3) puma (4.3.3)
nio4r (~> 2.0) nio4r (~> 2.0)
puma (4.3.3-java)
nio4r (~> 2.0)
rack (2.2.2) rack (2.2.2)
rack-proxy (0.6.5) rack-proxy (0.6.5)
rack rack
...@@ -147,6 +167,10 @@ GEM ...@@ -147,6 +167,10 @@ GEM
sassc-rails (~> 2.1, >= 2.1.1) sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.2.1) sassc (2.2.1)
ffi (~> 1.9) ffi (~> 1.9)
sassc (2.2.1-x64-mingw32)
ffi (~> 1.9)
sassc (2.2.1-x86-mingw32)
ffi (~> 1.9)
sassc-rails (2.1.2) sassc-rails (2.1.2)
railties (>= 4.0.0) railties (>= 4.0.0)
sassc (>= 2.0) sassc (>= 2.0)
...@@ -167,15 +191,17 @@ GEM ...@@ -167,15 +191,17 @@ 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.0.1) thor (1.0.1)
thread_safe (0.3.6) thread_safe (0.3.6)
thread_safe (0.3.6-java)
tilt (2.0.10) tilt (2.0.10)
turbolinks (5.2.1) turbolinks (5.2.1)
turbolinks-source (~> 5.2) turbolinks-source (~> 5.2)
turbolinks-source (5.2.0) turbolinks-source (5.2.0)
tzinfo (1.2.6) tzinfo (1.2.6)
thread_safe (~> 0.1) thread_safe (~> 0.1)
tzinfo-data (1.2019.3)
tzinfo (>= 1.0.0)
web-console (4.0.1) web-console (4.0.1)
actionview (>= 6.0.0) actionview (>= 6.0.0)
activemodel (>= 6.0.0) activemodel (>= 6.0.0)
...@@ -191,13 +217,19 @@ GEM ...@@ -191,13 +217,19 @@ GEM
railties (>= 4.2) railties (>= 4.2)
websocket-driver (0.7.1) websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-driver (0.7.1-java)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4) websocket-extensions (0.1.4)
xpath (3.2.0) xpath (3.2.0)
nokogiri (~> 1.8) nokogiri (~> 1.8)
zeitwerk (2.3.0) zeitwerk (2.3.0)
PLATFORMS PLATFORMS
java
ruby ruby
x64-mingw32
x86-mingw32
x86-mswin32
DEPENDENCIES DEPENDENCIES
bootsnap (>= 1.4.2) bootsnap (>= 1.4.2)
...@@ -205,13 +237,13 @@ DEPENDENCIES ...@@ -205,13 +237,13 @@ DEPENDENCIES
capybara (>= 2.15) capybara (>= 2.15)
jbuilder (~> 2.7) jbuilder (~> 2.7)
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
mysql2
puma (~> 4.1) puma (~> 4.1)
rails (~> 6.0.2, >= 6.0.2.2) rails (~> 6.0.2, >= 6.0.2.2)
sass-rails (>= 6) sass-rails (>= 6)
selenium-webdriver selenium-webdriver
spring spring
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
sqlite3 (~> 1.4)
turbolinks (~> 5) turbolinks (~> 5)
tzinfo-data tzinfo-data
web-console (>= 3.3.0) web-console (>= 3.3.0)
......
class Apply < ApplicationRecord
belongs_to :user
belongs_to :job
end
class City < ApplicationRecord
has_and_belongs_to_many :jobs
end
class CityJob < ApplicationRecord
belongs_to :city
belongs_to :job
end
class Company < ApplicationRecord
has_many :jobs
end
class Favorite < ApplicationRecord
belongs_to :user
belongs_to :job
end
class Industry < ApplicationRecord
has_and_belongs_to_many :jobs
end
class IndustryJob < ApplicationRecord
belongs_to :industry
belongs_to :job
end
class Job < ApplicationRecord
belongs_to :company
has_many :applies
has_many :users, through: :applies
has_many :favorites
has_many :users, through: :favorites
has_and_belongs_to_many :industries
has_and_belongs_to_many :cities
end
class User < ApplicationRecord
has_many :applies
has_many :jobs, through: :applies
has_many :favorites
has_many :jobs, through: :favorites
end
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default default: &default
adapter: sqlite3 adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: dev
password: dev
flags:
- -COMPRESS
- FOUND_ROWS
- MULTI_STATEMENTS
secure_auth: false
timeout: 5000 timeout: 5000
# 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
# re-generated from your development database when you run "rake".
# 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
username: venjob
password: <%= ENV['VENJOB_DATABASE_PASSWORD'] %>
\ No newline at end of file
class CreateJobs < ActiveRecord::Migration[6.0]
def change
create_table :jobs do |t|
t.string :title
t.string :updated_date_job
t.string :level
t.string :years_of_experience
t.string :salary
t.string :expiration_date
t.text :job_description
t.timestamps
end
end
end
class CreateCities < ActiveRecord::Migration[6.0]
def change
create_table :cities do |t|
t.string :title
t.timestamps
end
end
end
class CreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :full_name
t.string :email
t.string :password
t.string :cv_of_user
t.timestamps
end
end
end
class CreateCompanies < ActiveRecord::Migration[6.0]
def change
create_table :companies do |t|
t.string :title
t.string :address
t.string :logo
t.text :description
t.timestamps
end
end
end
class CreateIndustries < ActiveRecord::Migration[6.0]
def change
create_table :industries do |t|
t.string :title
t.timestamps
end
end
end
class AddReferencesCompanyToJobs < ActiveRecord::Migration[6.0]
def change
add_reference :jobs, :company, null: false, foreign_key: true
end
end
class CreateApplies < ActiveRecord::Migration[6.0]
def change
create_table :applies do |t|
t.references :user, null: false, foreign_key: true
t.references :job, null: false, foreign_key: true
t.timestamps
end
end
end
class CreateFavorites < ActiveRecord::Migration[6.0]
def change
create_table :favorites do |t|
t.references :user, null: false, foreign_key: true
t.references :job, null: false, foreign_key: true
t.timestamps
end
end
end
class CreateCityJob < ActiveRecord::Migration[6.0]
def change
create_table :city_jobs do |t|
t.references :city, null: false, foreign_key: true
t.references :job, null: false, foreign_key: true
end
end
end
class CreateIndustryJob < ActiveRecord::Migration[6.0]
def change
create_table :industry_jobs do |t|
t.references :industry, null: false, foreign_key: true
t.references :job, null: false, foreign_key: true
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 `rails
# db:schema:load`. When creating a new database, `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: 2020_03_20_101302) do
create_table "applies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", 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_applies_on_job_id"
t.index ["user_id"], name: "index_applies_on_user_id"
end
create_table "cities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "title"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "city_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.bigint "city_id", null: false
t.bigint "job_id", null: false
t.index ["city_id"], name: "index_city_jobs_on_city_id"
t.index ["job_id"], name: "index_city_jobs_on_job_id"
end
create_table "companies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "title"
t.string "address"
t.string "logo"
t.text "description"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "favorites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", 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_favorites_on_job_id"
t.index ["user_id"], name: "index_favorites_on_user_id"
end
create_table "industries", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "title"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "industry_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.bigint "industry_id", null: false
t.bigint "job_id", null: false
t.index ["industry_id"], name: "index_industry_jobs_on_industry_id"
t.index ["job_id"], name: "index_industry_jobs_on_job_id"
end
create_table "jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "title"
t.string "updated_date_job"
t.string "level"
t.string "years_of_experience"
t.string "salary"
t.string "expiration_date"
t.text "job_description"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.bigint "company_id", null: false
t.index ["company_id"], name: "index_jobs_on_company_id"
end
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "full_name"
t.string "email"
t.string "password"
t.string "cv_of_user"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
add_foreign_key "applies", "jobs"
add_foreign_key "applies", "users"
add_foreign_key "city_jobs", "cities"
add_foreign_key "city_jobs", "jobs"
add_foreign_key "favorites", "jobs"
add_foreign_key "favorites", "users"
add_foreign_key "industry_jobs", "industries"
add_foreign_key "industry_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