Add types to Poll Shifts as an enum

This commit is contained in:
Bertocq
2017-09-27 13:33:58 +02:00
parent 45f34540ae
commit 1dde4cb3ec
3 changed files with 10 additions and 1 deletions

View File

@@ -7,6 +7,9 @@ class Poll
validates :officer_id, presence: true
validates :date, presence: true
validates :date, uniqueness: { scope: [:officer_id, :booth_id] }
validates :task, presence: true
enum task: { vote_collection: 0, recount_scrutiny: 1 }
before_create :persist_data
after_create :create_officer_assignments

View File

@@ -0,0 +1,5 @@
class AddShiftTask < ActiveRecord::Migration
def change
add_column :poll_shifts, :task, :integer, null: false, default: 0
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170918231410) do
ActiveRecord::Schema.define(version: 20170927110953) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -687,6 +687,7 @@ ActiveRecord::Schema.define(version: 20170918231410) do
t.datetime "updated_at"
t.string "officer_name"
t.string "officer_email"
t.integer "task", default: 0, null: false
end
add_index "poll_shifts", ["booth_id", "officer_id"], name: "index_poll_shifts_on_booth_id_and_officer_id", using: :btree