Merge branch 'master' into iss-1192-test

This commit is contained in:
Raimond Garcia
2017-04-12 11:51:48 +02:00
committed by GitHub
406 changed files with 11980 additions and 1214 deletions

View File

@@ -0,0 +1,7 @@
class CreatePolls < ActiveRecord::Migration
def change
create_table :polls do |t|
t.string :name
end
end
end

View File

@@ -0,0 +1,7 @@
class CreatePollOfficers < ActiveRecord::Migration
def change
create_table :poll_officers do |t|
t.integer :user_id
end
end
end

View File

@@ -0,0 +1,9 @@
class CreatePollVoters < ActiveRecord::Migration
def change
create_table :poll_voters do |t|
t.integer :booth_id
t.string :document_number
t.string :document_type
end
end
end

View File

@@ -0,0 +1,8 @@
class CreatePollBooths < ActiveRecord::Migration
def change
create_table :poll_booths do |t|
t.string :name
t.integer :poll_id
end
end
end

View File

@@ -0,0 +1,5 @@
class AddLocationToBooths < ActiveRecord::Migration
def change
add_column :poll_booths, :location, :string
end
end

View File

@@ -0,0 +1,9 @@
class CreateOfficingBooths < ActiveRecord::Migration
def change
create_table :poll_officing_booths do |t|
t.belongs_to :officer
t.belongs_to :booth
t.timestamps null: false
end
end
end

View File

@@ -0,0 +1,6 @@
class AddDatesToPolls < ActiveRecord::Migration
def change
add_column :polls, :starts_at, :datetime
add_column :polls, :ends_at, :datetime
end
end

View File

@@ -0,0 +1,21 @@
class CreatePollQuestions < ActiveRecord::Migration
def change
create_table :poll_questions do |t|
t.references :proposal, index: true, foreign_key: true
t.references :poll, index: true, foreign_key: true
t.references :author, index: true # foreign key added later due to rails 4
t.string :author_visible_name
t.string :title
t.string :question
t.string :summary
t.string :valid_answers
t.text :description
t.integer :comments_count
t.datetime :hidden_at
t.timestamps
end
add_foreign_key :poll_questions, :users, column: :author_id
end
end

View File

@@ -0,0 +1,10 @@
class CreateGeozonesPollQuestions < ActiveRecord::Migration
def change
create_table :geozones_poll_questions do |t|
t.references :geozone, index: true, foreign_key: true
t.integer :question_id, index: true
end
add_foreign_key :geozones_poll_questions, :poll_questions, column: :question_id
end
end

View File

@@ -0,0 +1,5 @@
class AddAllGeozonesToPollQuestions < ActiveRecord::Migration
def change
add_column :poll_questions, :all_geozones, :boolean, default: false
end
end

View File

@@ -0,0 +1,14 @@
class CreatePollPartialResult < ActiveRecord::Migration
def change
create_table :poll_partial_results do |t|
t.integer :question_id, index: true
t.integer :author_id, index: true
t.string :answer, index: true
t.integer :amount
t.string :origin, index: true
end
add_foreign_key(:poll_partial_results, :users, column: :author_id)
add_foreign_key(:poll_partial_results, :poll_questions, column: :question_id)
end
end

View File

@@ -0,0 +1,5 @@
class RemoveQuestionFromPollQuestions < ActiveRecord::Migration
def change
remove_column :poll_questions, :question
end
end

View File

@@ -0,0 +1,11 @@
class AddTsvToPollQuestions < ActiveRecord::Migration
def up
add_column :poll_questions, :tsv, :tsvector
add_index :poll_questions, :tsv, using: "gin"
end
def down
remove_index :poll_questions, :tsv
remove_column :poll_questions, :tsv
end
end

View File

@@ -0,0 +1,5 @@
class RemovePollIdFromBooth < ActiveRecord::Migration
def change
remove_column :poll_booths, :poll_id, :integer
end
end

View File

@@ -0,0 +1,9 @@
class CreatePollBoothAssignments < ActiveRecord::Migration
def change
create_table :poll_booth_assignments do |t|
t.integer :booth_id
t.integer :poll_id
t.timestamps null: false
end
end
end

View File

@@ -0,0 +1,8 @@
class DeleteOfficingBooths < ActiveRecord::Migration
def self.up
drop_table :poll_officing_booths
end
def self.down
end
end

View File

@@ -0,0 +1,9 @@
class CreatePollOfficerAssignments < ActiveRecord::Migration
def change
create_table :poll_officer_assignments do |t|
t.integer :booth_assignment_id
t.integer :officer_id
t.timestamps null: false
end
end
end

View File

@@ -0,0 +1,10 @@
class RenameBoothIdToBoothAssignmentId < ActiveRecord::Migration
def change
remove_column :poll_voters, :booth_id, :integer
add_column :poll_voters, :booth_assignment_id, :integer, null: false
add_column :poll_voters, :poll_id, :integer, null: false
add_column :poll_voters, :created_at, :datetime, null: false
add_column :poll_voters, :updated_at, :datetime, null: false
end
end

View File

@@ -0,0 +1,5 @@
class RemovePollIdFromVoter < ActiveRecord::Migration
def change
remove_column :poll_voters, :poll_id, :integer
end
end

View File

@@ -0,0 +1,5 @@
class AddDateToOfficerAssignment < ActiveRecord::Migration
def change
add_column :poll_officer_assignments, :date, :datetime
end
end

View File

@@ -0,0 +1,15 @@
class CreatePollRecounts < ActiveRecord::Migration
def change
create_table :poll_recounts do |t|
t.integer :booth_assignment_id
t.integer :officer_assignment_id
t.integer :count
t.text :count_log, default: ""
t.timestamps null: false
end
add_index :poll_recounts, :booth_assignment_id
add_index :poll_recounts, :officer_assignment_id
end
end

View File

@@ -0,0 +1,5 @@
class AddPublishedToPolls < ActiveRecord::Migration
def change
add_column :polls, :published, :boolean, default: false
end
end

View File

@@ -0,0 +1,6 @@
class AddDateAndOfficerAssignmentLogToPollRecounts < ActiveRecord::Migration
def change
add_column :poll_recounts, :date, :datetime
add_column :poll_recounts, :officer_assignment_id_log, :text, default: ""
end
end

View File

@@ -0,0 +1,10 @@
class MoveGeozonesFromPollQuestionsToPolls < ActiveRecord::Migration
def change
drop_table :geozones_poll_questions
create_table :geozones_polls do |t|
t.references :geozone, index: true, foreign_key: true
t.references :poll, index: true, foreign_key: true
end
end
end

View File

@@ -0,0 +1,5 @@
class AddGeozoneRestrictedToPolls < ActiveRecord::Migration
def change
add_column :polls, :geozone_restricted, :boolean, default: false, index: true
end
end

View File

@@ -0,0 +1,5 @@
class RemoveAllGeozonesFromPollQuestions < ActiveRecord::Migration
def change
remove_column :poll_questions, :all_geozones, :boolean
end
end

View File

@@ -0,0 +1,12 @@
class AddPollIdAndStatsFieldsToPollVoter < ActiveRecord::Migration
def change
add_column :poll_voters, :poll_id, :integer, null: false
remove_column :poll_voters, :booth_assignment_id, :integer, null: false
add_column :poll_voters, :booth_assignment_id, :integer
add_column :poll_voters, :age, :integer
add_column :poll_voters, :gender, :string
add_column :poll_voters, :geozone_id, :integer
end
end

View File

@@ -0,0 +1,15 @@
class CreatePollAnswers < ActiveRecord::Migration
def change
create_table :poll_answers do |t|
t.integer :question_id
t.integer :author_id
t.string :answer
t.timestamps
end
add_index :poll_answers, :question_id
add_index :poll_answers, :author_id
add_index :poll_answers, [:question_id, :answer]
end
end

View File

@@ -0,0 +1,9 @@
class AddAnswerIdToPollVoters < ActiveRecord::Migration
def change
add_column :poll_voters, :answer_id, :integer, default: nil
add_index :poll_voters, :document_number
add_index :poll_voters, :poll_id
add_index :poll_voters, [:poll_id, :document_number, :document_type], name: 'doc_by_poll'
end
end

View File

@@ -0,0 +1,5 @@
class AddOfficerAssignmentToVotes < ActiveRecord::Migration
def change
add_column :poll_voters, :officer_assignment_id, :integer, default: nil
end
end

View File

@@ -0,0 +1,5 @@
class AddsUserIdToPollVoters < ActiveRecord::Migration
def change
add_reference :poll_voters, :user, index: true
end
end

View File

@@ -0,0 +1,15 @@
class CreatePollFinalRecount < ActiveRecord::Migration
def change
create_table :poll_final_recounts do |t|
t.integer :booth_assignment_id
t.integer :officer_assignment_id
t.integer :count
t.text :count_log, default: ""
t.datetime :created_at, null: false
t.datetime :updated_at, null: false
t.text :officer_assignment_id_log, default: ""
end
add_index :poll_final_recounts, :booth_assignment_id
end
end

View File

@@ -0,0 +1,5 @@
class AddFinalToPollOfficerAssignments < ActiveRecord::Migration
def change
add_column :poll_officer_assignments, :final, :boolean, default: false
end
end

View File

@@ -0,0 +1,5 @@
class AddDateToFinalRecount < ActiveRecord::Migration
def change
add_column :poll_final_recounts, :date, :datetime, null: false
end
end

View File

@@ -0,0 +1,13 @@
class ChangeDatetimesToDateInRecountsAndAssignments < ActiveRecord::Migration
def up
change_column :poll_recounts, :date, :date, null: false
change_column :poll_final_recounts, :date, :date, null: false
change_column :poll_officer_assignments, :date, :date, null: false
end
def down
change_column :poll_recounts, :date, :datetime, null: false
change_column :poll_final_recounts, :date, :datetime, null: false
change_column :poll_officer_assignments, :date, :datetime, null: false
end
end

View File

@@ -0,0 +1,5 @@
class RemoveSummaryFromPollQuestion < ActiveRecord::Migration
def change
remove_column :poll_questions, :summary
end
end

View File

@@ -0,0 +1,9 @@
class AddsFieldsToPollPartialResults < ActiveRecord::Migration
def change
add_column :poll_partial_results, :date, :date
add_column :poll_partial_results, :booth_assignment_id, :integer
add_column :poll_partial_results, :officer_assignment_id, :integer
add_index :poll_partial_results, [:booth_assignment_id, :date]
end
end

View File

@@ -0,0 +1,7 @@
class AddLogFieldsToPollPartialResults < ActiveRecord::Migration
def change
add_column :poll_partial_results, :amount_log, :text, default: ""
add_column :poll_partial_results, :officer_assignment_id_log, :text, default: ""
add_column :poll_partial_results, :author_id_log, :text, default: ""
end
end

View File

@@ -0,0 +1,18 @@
class CreatePollWhiteResults < ActiveRecord::Migration
def change
create_table :poll_white_results do |t|
t.integer :author_id
t.integer :amount
t.string :origin
t.date :date
t.integer :booth_assignment_id
t.integer :officer_assignment_id
t.text :amount_log, default: ""
t.text :officer_assignment_id_log, default: ""
t.text :author_id_log, default: ""
end
add_index :poll_white_results, :officer_assignment_id
add_index :poll_white_results, :booth_assignment_id
end
end

View File

@@ -0,0 +1,18 @@
class CreatePollNullResults < ActiveRecord::Migration
def change
create_table :poll_null_results do |t|
t.integer :author_id
t.integer :amount
t.string :origin
t.date :date
t.integer :booth_assignment_id
t.integer :officer_assignment_id
t.text :amount_log, default: ""
t.text :officer_assignment_id_log, default: ""
t.text :author_id_log, default: ""
end
add_index :poll_null_results, :officer_assignment_id
add_index :poll_null_results, :booth_assignment_id
end
end

View File

@@ -0,0 +1,6 @@
class AddOfficerIdToFailedCensusCalls < ActiveRecord::Migration
def change
add_column :failed_census_calls, :poll_officer_id, :integer, index: true
add_foreign_key :failed_census_calls, :poll_officers
end
end

View File

@@ -0,0 +1,5 @@
class AddFailedCensusCallsCountToPollOfficers < ActiveRecord::Migration
def change
add_column :poll_officers, :failed_census_calls_count, :integer, default: 0
end
end

View File

@@ -0,0 +1,5 @@
class AddYearOfBirthToFailedCensusCalls < ActiveRecord::Migration
def change
add_column :failed_census_calls, :year_of_birth, :integer
end
end

View File

@@ -0,0 +1,5 @@
class AddUserDataLogToPollOfficerAssignments < ActiveRecord::Migration
def change
add_column :poll_officer_assignments, :user_data_log, :string, default: ""
end
end

View File

@@ -0,0 +1,5 @@
class AddFormerUsersDataLogToUsers < ActiveRecord::Migration
def change
add_column :users, :former_users_data_log, :text, default: ""
end
end

View File

@@ -0,0 +1,36 @@
class AddPollsRelatedIndexes < ActiveRecord::Migration
def change
add_index :poll_booth_assignments, :booth_id
add_index :poll_booth_assignments, :poll_id
add_index :poll_final_recounts, :officer_assignment_id
add_index :poll_officer_assignments, :booth_assignment_id
add_index :poll_officer_assignments, :officer_id
add_index :poll_officer_assignments, [:officer_id, :date]
add_index :poll_officers, :user_id
add_index :poll_voters, :booth_assignment_id
add_index :poll_voters, :officer_assignment_id
add_index :polls, [:starts_at, :ends_at]
add_foreign_key :poll_answers, :poll_questions, column: :question_id
add_foreign_key :poll_booth_assignments, :polls
add_foreign_key :poll_final_recounts, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_final_recounts, :poll_officer_assignments, column: :officer_assignment_id
add_foreign_key :poll_null_results, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_null_results, :poll_officer_assignments, column: :officer_assignment_id
add_foreign_key :poll_white_results, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_white_results, :poll_officer_assignments, column: :officer_assignment_id
add_foreign_key :poll_officer_assignments, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_partial_results, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_partial_results, :poll_officer_assignments, column: :officer_assignment_id
add_foreign_key :poll_voters, :polls
add_foreign_key :poll_recounts, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_recounts, :poll_officer_assignments, column: :officer_assignment_id
end
end

View File

@@ -0,0 +1,15 @@
class CreateSiteCustomizationPages < ActiveRecord::Migration
def change
create_table :site_customization_pages do |t|
t.string :slug, null: false
t.string :title, null: false
t.string :subtitle
t.text :content
t.boolean :more_info_flag
t.boolean :print_content_flag
t.string :status, default: 'draft'
t.timestamps null: false
end
end
end

View File

@@ -0,0 +1,11 @@
class CreateSiteCustomizationImages < ActiveRecord::Migration
def change
create_table :site_customization_images do |t|
t.string :name, null: false
t.attachment :image
t.timestamps null: false
end
add_index :site_customization_images, :name, unique: true
end
end

View File

@@ -0,0 +1,13 @@
class CreateSiteCustomizationContentBlocks < ActiveRecord::Migration
def change
create_table :site_customization_content_blocks do |t|
t.string :name
t.string :locale
t.text :body
t.timestamps null: false
end
add_index :site_customization_content_blocks, [:name, :locale], unique: true
end
end