models and fixtures and seeds
This commit is contained in:
63
db/migrate/20160726193255_db_init.rb
Normal file
63
db/migrate/20160726193255_db_init.rb
Normal file
@ -0,0 +1,63 @@
|
||||
class DbInit < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :candidates do |t|
|
||||
t.string :test_hash, null: false
|
||||
t.string :name
|
||||
t.string :email
|
||||
t.string :experience
|
||||
t.integer :recruiter_id
|
||||
t.boolean :completed, null: false, default: false
|
||||
t.boolean :reminded, null: false, default: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :candidates, :test_hash, unique: true
|
||||
add_index :candidates, :recruiter_id
|
||||
|
||||
create_table :questions do |t|
|
||||
t.integer :quiz_id
|
||||
t.text :question
|
||||
t.string :category
|
||||
t.string :input_type
|
||||
t.text :input_options
|
||||
t.string :sort, null: false, default: 0
|
||||
t.boolean :active, null: false, default: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :questions, :quiz_id
|
||||
add_index :questions, :sort
|
||||
add_index :questions, :active
|
||||
|
||||
create_table :answers do |t|
|
||||
t.integer :candidate_id
|
||||
t.integer :question_id
|
||||
t.text :answer
|
||||
t.integer :saved, null: false, default: 0
|
||||
t.boolean :submitted, null: false, default: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :answers, :candidate_id
|
||||
add_index :answers, :question_id
|
||||
add_index :answers, :submitted
|
||||
|
||||
create_table :quizzes do |t|
|
||||
t.string :unit
|
||||
t.string :dept
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :users do |t|
|
||||
t.string :name, null: false
|
||||
t.string :email, null: false
|
||||
t.string :password_digest
|
||||
t.string :role, null: false
|
||||
t.boolean :active, null: false, default: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :users, :email, unique: true
|
||||
end
|
||||
end
|
61
db/schema.rb
61
db/schema.rb
@ -10,6 +10,65 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 0) do
|
||||
ActiveRecord::Schema.define(version: 20160726193255) do
|
||||
|
||||
create_table "answers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.integer "candidate_id"
|
||||
t.integer "question_id"
|
||||
t.text "answer", limit: 65535
|
||||
t.integer "saved"
|
||||
t.boolean "submitted"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["candidate_id"], name: "index_answers_on_candidate_id", using: :btree
|
||||
t.index ["question_id"], name: "index_answers_on_question_id", using: :btree
|
||||
t.index ["submitted"], name: "index_answers_on_submitted", using: :btree
|
||||
end
|
||||
|
||||
create_table "candidates", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.string "test_hash"
|
||||
t.string "name"
|
||||
t.string "email"
|
||||
t.string "experience"
|
||||
t.integer "recruiter_id"
|
||||
t.boolean "completed"
|
||||
t.boolean "reminded"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["recruiter_id"], name: "index_candidates_on_recruiter_id", using: :btree
|
||||
t.index ["test_hash"], name: "index_candidates_on_test_hash", unique: true, using: :btree
|
||||
end
|
||||
|
||||
create_table "questions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.integer "quiz_id"
|
||||
t.text "question", limit: 65535
|
||||
t.string "category"
|
||||
t.string "input_type"
|
||||
t.text "input_options", limit: 65535
|
||||
t.string "sort"
|
||||
t.boolean "active"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["active"], name: "index_questions_on_active", using: :btree
|
||||
t.index ["quiz_id"], name: "index_questions_on_quiz_id", using: :btree
|
||||
t.index ["sort"], name: "index_questions_on_sort", using: :btree
|
||||
end
|
||||
|
||||
create_table "quizzes", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.string "unit"
|
||||
t.string "dept"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.string "name"
|
||||
t.string "email"
|
||||
t.string "password_digest"
|
||||
t.string "role"
|
||||
t.boolean "active"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -5,3 +5,12 @@
|
||||
#
|
||||
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
||||
# Character.create(name: 'Luke', movie: movies.first)
|
||||
|
||||
User.create(
|
||||
name: 'admin',
|
||||
email: 'pdr.admin@mailinator.com',
|
||||
password_digest: BCrypt::Password.create("this is the admin password"),
|
||||
role: 'admin'
|
||||
)
|
||||
|
||||
Quiz.create(unit: 'FED', dept: 'PDR')
|
||||
|
Reference in New Issue
Block a user