Commit 5774f9b2 by Xuan Trung Le

Fix creating db

parent 201393d4
class IndustryJob < ApplicationRecord class IndustriesJob < ApplicationRecord
belongs_to :industry belongs_to :industry
belongs_to :job belongs_to :job
end end
...@@ -14,7 +14,7 @@ default: &default ...@@ -14,7 +14,7 @@ default: &default
encoding: utf8 encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root username: root
password: <%= ENV["password_mysql"] %> password: <%= ENV["PASSWORD_MYSQL"] %>
socket: /var/run/mysqld/mysqld.sock socket: /var/run/mysqld/mysqld.sock
development: development:
......
...@@ -2,7 +2,7 @@ class CreateCities < ActiveRecord::Migration[5.1] ...@@ -2,7 +2,7 @@ class CreateCities < ActiveRecord::Migration[5.1]
def change def change
create_table :cities do |t| create_table :cities do |t|
t.string :name t.string :name
t.references :country t.references :country, index: true
t.timestamps t.timestamps
end end
......
...@@ -4,7 +4,7 @@ class CreateCompanies < ActiveRecord::Migration[5.1] ...@@ -4,7 +4,7 @@ class CreateCompanies < ActiveRecord::Migration[5.1]
t.string :name t.string :name
t.string :location t.string :location
t.text :description t.text :description
t.references :city t.references :city, index: true
t.timestamps t.timestamps
end end
......
...@@ -6,8 +6,8 @@ class CreateJobs < ActiveRecord::Migration[5.1] ...@@ -6,8 +6,8 @@ class CreateJobs < ActiveRecord::Migration[5.1]
t.text :description t.text :description
t.string :level t.string :level
t.string :experience t.string :experience
t.references :city t.references :city, index: true
t.references :company t.references :company, index: true
t.datetime :expiry_date t.datetime :expiry_date
t.datetime :updated_date t.datetime :updated_date
t.datetime :updated_at t.datetime :updated_at
......
class CreateFavoriteJobs < ActiveRecord::Migration[5.1] class CreateFavoriteJobs < ActiveRecord::Migration[5.1]
def change def change
create_table :favorite_jobs do |t| create_table :favorite_jobs do |t|
t.references :job t.references :job, index: true
t.references :user t.references :user, index: true
t.timestamps t.timestamps
end end
......
class CreateApplyJobs < ActiveRecord::Migration[5.1] class CreateApplyJobs < ActiveRecord::Migration[5.1]
def change def change
create_table :apply_jobs do |t| create_table :apply_jobs do |t|
t.references :job t.references :job, index: true
t.references :user t.references :user, index: true
t.string :cv t.string :cv
t.timestamps t.timestamps
......
class CreateIndustryJobs < ActiveRecord::Migration[5.1] class CreateIndustriesJobs < ActiveRecord::Migration[5.1]
def change def change
create_table :industry_jobs do |t| create_table :industries_jobs do |t|
t.references :industry t.references :industry, index: true
t.references :job t.references :job, index: true
t.timestamps t.timestamps
end end
......
class AddCvNameToUsers < ActiveRecord::Migration[5.1]
def change
add_column :users, :cv, :string
add_column :users, :name, :string
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.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171002033456) do
create_table "apply_jobs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.bigint "job_id"
t.bigint "user_id"
t.string "cv"
t.datetime "created_at", null: false
t.datetime "updated_at", 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", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
t.bigint "country_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["country_id"], name: "index_cities_on_country_id"
end
create_table "companies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
t.string "location"
t.text "description"
t.bigint "city_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["city_id"], name: "index_companies_on_city_id"
end
create_table "countries", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "favorite_jobs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.bigint "job_id"
t.bigint "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", 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 "industries", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "industries_jobs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.bigint "industry_id"
t.bigint "job_id"
t.datetime "created_at", null: false
t.datetime "updated_at", 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", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
t.string "salary"
t.text "description"
t.string "level"
t.string "experience"
t.bigint "city_id"
t.bigint "company_id"
t.datetime "expiry_date"
t.datetime "updated_date"
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.index ["city_id"], name: "index_jobs_on_city_id"
t.index ["company_id"], name: "index_jobs_on_company_id"
end
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "cv"
t.string "name"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
end
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
industry: one
job: one
two:
industry: two
job: two
require 'test_helper'
class IndustriesJobTest < 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