Commit 82d540fb by nnnghia98

change method up/down

parent 399d6ba9
class CreateUsers < ActiveRecord::Migration[6.0] class CreateUsers < ActiveRecord::Migration[6.0]
def change def up
create_table :users do |t| create_table :users do |t|
t.string :first_name t.string :first_name
t.string :last_name t.string :last_name
...@@ -48,4 +48,8 @@ class CreateUsers < ActiveRecord::Migration[6.0] ...@@ -48,4 +48,8 @@ class CreateUsers < ActiveRecord::Migration[6.0]
# add_index :users, :confirmation_token, unique: true # add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, unique: true # add_index :users, :unlock_token, unique: true
end end
def down
drop_table :users
end
end end
class CreateJobs < ActiveRecord::Migration[6.0] class CreateJobs < ActiveRecord::Migration[6.0]
def change def up
create_table :jobs do |t| create_table :jobs do |t|
t.string :title t.string :title
t.string :level t.string :level
...@@ -11,9 +11,13 @@ class CreateJobs < ActiveRecord::Migration[6.0] ...@@ -11,9 +11,13 @@ class CreateJobs < ActiveRecord::Migration[6.0]
t.integer :category t.integer :category
t.datetime :post_date t.datetime :post_date
t.datetime :expiration_date t.datetime :expiration_date
t.references :company, null: false, foreign_key: true t.string :company_id
t.timestamps t.timestamps
end end
end end
def down
drop_table :jobs
end
end end
class CreateUserJobs < ActiveRecord::Migration[6.0] class CreateUserJobs < ActiveRecord::Migration[6.0]
def change def change
create_table :user_jobs do |t| create_table :user_jobs do |t|
t.references :user, null: false, foreign_key: true t.string :user_id
t.references :job, null: false, foreign_key: true t.string :job_id
t.datetime :applied_at t.datetime :applied_at
t.datetime :viewed_at t.datetime :viewed_at
t.datetime :favorited_at t.datetime :favorited_at
......
class CreateCityJobs < ActiveRecord::Migration[6.0] class CreateCityJobs < ActiveRecord::Migration[6.0]
def change def change
create_table :city_jobs do |t| create_table :city_jobs do |t|
t.references :city, null: false, foreign_key: true t.string :city_id
t.references :job, null: false, foreign_key: true t.string :job_id
t.timestamps t.timestamps
end end
......
class CreateIndustryJobs < ActiveRecord::Migration[6.0] class CreateIndustryJobs < ActiveRecord::Migration[6.0]
def change def change
create_table :industry_jobs do |t| create_table :industry_jobs do |t|
t.references :industry, null: false, foreign_key: true t.string :industry_id
t.references :job, null: false, foreign_key: true t.string :job_id
t.timestamps t.timestamps
end end
......
...@@ -17,15 +17,14 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do ...@@ -17,15 +17,14 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
t.string "region" t.string "region"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.index ["name"], name: "index_cities_on_name", unique: true
end end
create_table "city_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "city_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.bigint "city_id", null: false t.string "city_id"
t.bigint "job_id", null: false t.string "job_id"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, 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 end
create_table "companies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "companies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
...@@ -35,6 +34,7 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do ...@@ -35,6 +34,7 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
t.string "address" t.string "address"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.index ["email"], name: "index_companies_on_email", unique: true
end end
create_table "crawl_urls", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "crawl_urls", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
...@@ -52,12 +52,10 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do ...@@ -52,12 +52,10 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
end end
create_table "industry_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "industry_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.bigint "industry_id", null: false t.string "industry_id"
t.bigint "job_id", null: false t.string "job_id"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, 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 end
create_table "jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
...@@ -71,22 +69,19 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do ...@@ -71,22 +69,19 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
t.integer "category" t.integer "category"
t.datetime "post_date" t.datetime "post_date"
t.datetime "expiration_date" t.datetime "expiration_date"
t.bigint "company_id", null: false t.string "company_id"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.index ["company_id"], name: "index_jobs_on_company_id"
end end
create_table "user_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "user_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.bigint "user_id", null: false t.string "user_id"
t.bigint "job_id", null: false t.string "job_id"
t.datetime "applied_at" t.datetime "applied_at"
t.datetime "viewed_at" t.datetime "viewed_at"
t.datetime "favorited_at" t.datetime "favorited_at"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.index ["job_id"], name: "index_user_jobs_on_job_id"
t.index ["user_id"], name: "index_user_jobs_on_user_id"
end end
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
...@@ -111,11 +106,4 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do ...@@ -111,11 +106,4 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
t.index ["username"], name: "index_users_on_username", unique: true t.index ["username"], name: "index_users_on_username", unique: true
end end
add_foreign_key "city_jobs", "cities"
add_foreign_key "city_jobs", "jobs"
add_foreign_key "industry_jobs", "industries"
add_foreign_key "industry_jobs", "jobs"
add_foreign_key "jobs", "companies"
add_foreign_key "user_jobs", "jobs"
add_foreign_key "user_jobs", "users"
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