Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcdfbbd
commit 38bfd44
Showing
28 changed files
with
474 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
db/migrate/20180319135724_create_decidim_consultations.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This migration comes from decidim_consultations (originally 20180109092205) | ||
# frozen_string_literal: true | ||
|
||
class CreateDecidimConsultations < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :decidim_consultations do |t| | ||
t.string :slug, null: false | ||
t.integer :decidim_organization_id, | ||
foreign_key: true, | ||
index: { | ||
name: "index_decidim_consultations_on_decidim_organization_id" | ||
} | ||
|
||
t.index [:decidim_organization_id, :slug], | ||
name: "index_unique_consultation_slug_and_organization", | ||
unique: true | ||
|
||
t.jsonb :title, null: false | ||
t.jsonb :subtitle, null: false | ||
t.jsonb :description, null: false | ||
|
||
# Text search indexes for consultations. | ||
t.index :title, name: "decidim_consultations_title_search" | ||
t.index :subtitle, name: "decidim_consultations_subtitle_search" | ||
t.index :description, name: "decidim_consultations_description_search" | ||
|
||
t.string :banner_image | ||
t.string :introductory_video_url | ||
t.date :start_voting_date, null: false | ||
t.integer :decidim_highlighted_scope_id, index: true | ||
|
||
# Publicable | ||
t.datetime :published_at, index: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
36 changes: 36 additions & 0 deletions
36
db/migrate/20180319135725_create_decidim_consultations_questions.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This migration comes from decidim_consultations (originally 20180112053247) | ||
# frozen_string_literal: true | ||
|
||
class CreateDecidimConsultationsQuestions < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :decidim_consultations_questions do |t| | ||
t.references :decidim_consultation, index: { name: "index_consultations_questions_on_consultation_id" } | ||
t.references :decidim_scope | ||
|
||
t.jsonb :title, null: false | ||
t.jsonb :subtitle, null: false | ||
t.jsonb :what_is_decided, null: false | ||
t.jsonb :promoter_group, null: false | ||
t.jsonb :participatory_scope, null: false | ||
t.jsonb :question_context | ||
|
||
# Text search indexes for consultation questions. | ||
t.index :title, name: "consultation_questions_title_search" | ||
t.index :subtitle, name: "consultation_questions_subtitle_search" | ||
t.index :what_is_decided, name: "consultation_questions_what_is_decided_search" | ||
t.index :promoter_group, name: "consultation_question_promoter_group_search" | ||
t.index :participatory_scope, name: "consultation_question_participatory_scope_search" | ||
t.index :question_context, name: "consultation_question_context_search" | ||
|
||
t.string :banner_image | ||
t.string :introductory_video_url | ||
t.string :reference | ||
t.string :hashtag | ||
|
||
# Publicable | ||
t.datetime :published_at, index: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
...rate/20180319135726_add_end_voting_date_to_decidim_consultations.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This migration comes from decidim_consultations (originally 20180115132000) | ||
# frozen_string_literal: true | ||
|
||
class AddEndVotingDateToDecidimConsultations < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations, :end_voting_date, :date | ||
|
||
Decidim::Consultation.find_each do |consultation| | ||
consultation.end_voting_date = consultation.start_voting_date + 1.month | ||
consultation.save | ||
end | ||
|
||
change_column_null :decidim_consultations, :end_voting_date, false | ||
end | ||
end |
29 changes: 29 additions & 0 deletions
29
...grate/20180319135727_add_slug_to_decidim_consultations_questions.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This migration comes from decidim_consultations (originally 20180115170933) | ||
# frozen_string_literal: true | ||
|
||
class AddSlugToDecidimConsultationsQuestions < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations_questions, | ||
:decidim_organization_id, | ||
:integer, | ||
index: { | ||
name: "index_decidim_questions_on_decidim_organization_id" | ||
} | ||
|
||
add_column :decidim_consultations_questions, :slug, :string | ||
|
||
Decidim::Consultations::Question.find_each do |question| | ||
question.decidim_organization_id = question.consultation.decidim_organization_id | ||
question.slug = "q-#{question.id}" | ||
question.save | ||
end | ||
|
||
change_column_null :decidim_consultations_questions, :decidim_organization_id, false | ||
change_column_null :decidim_consultations_questions, :slug, false | ||
|
||
add_index :decidim_consultations_questions, | ||
[:decidim_organization_id, :slug], | ||
name: "index_unique_question_slug_and_organization", | ||
unique: true | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
db/migrate/20180319135728_create_decidim_consultations_votes.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# This migration comes from decidim_consultations (originally 20180119084217) | ||
# frozen_string_literal: true | ||
|
||
class CreateDecidimConsultationsVotes < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :decidim_consultations_votes do |t| | ||
t.references :decidim_consultation_question, index: { name: "index_consultations_votes_on_consultation_question" } | ||
t.references :decidim_author, index: { name: "index_consultations_votes_on_author" } | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :decidim_consultations_votes, | ||
%i[decidim_consultation_question_id decidim_author_id], | ||
unique: true, | ||
name: "index_question_votes_author_unique" | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
...20180319135729_add_votes_count_to_decidim_consultations_question.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This migration comes from decidim_consultations (originally 20180119084331) | ||
# frozen_string_literal: true | ||
|
||
class AddVotesCountToDecidimConsultationsQuestion < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations_questions, :votes_count, :integer, null: false, default: 0 | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
...180319135730_add_origin_scope_to_decidim_consultations_questions.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This migration comes from decidim_consultations (originally 20180122113155) | ||
# frozen_string_literal: true | ||
|
||
class AddOriginScopeToDecidimConsultationsQuestions < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations_questions, :origin_scope, :jsonb | ||
add_index :decidim_consultations_questions, :origin_scope, name: "consultation_questions_origin_scope_search" | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
...180319135731_add_origin_title_to_decidim_consultations_questions.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This migration comes from decidim_consultations (originally 20180122113400) | ||
# frozen_string_literal: true | ||
|
||
class AddOriginTitleToDecidimConsultationsQuestions < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations_questions, :origin_title, :jsonb | ||
add_index :decidim_consultations_questions, :origin_title, name: "consultation_questions_origin_title_search" | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
...80319135732_add_origin_string_to_decidim_consultations_questions.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This migration comes from decidim_consultations (originally 20180122113447) | ||
# frozen_string_literal: true | ||
|
||
class AddOriginStringToDecidimConsultationsQuestions < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations_questions, :origin_url, :string | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
...319135733_add_enable_highlighted_banner_to_decidim_consultations.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This migration comes from decidim_consultations (originally 20180126142459) | ||
# frozen_string_literal: true | ||
|
||
class AddEnableHighlightedBannerToDecidimConsultations < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations, :enable_highlighted_banner, :boolean, null: false, default: true | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
...0180319135734_add_i_frame_url_to_decidim_consultations_questions.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This migration comes from decidim_consultations (originally 20180129063438) | ||
# frozen_string_literal: true | ||
|
||
class AddIFrameUrlToDecidimConsultationsQuestions < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations_questions, :i_frame_url, :string | ||
add_column :decidim_consultations_questions, :external_voting, :boolean | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
db/migrate/20180319135735_create_decidim_consultations_responses.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This migration comes from decidim_consultations (originally 20180129063700) | ||
# frozen_string_literal: true | ||
|
||
class CreateDecidimConsultationsResponses < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :decidim_consultations_responses do |t| | ||
t.jsonb :title | ||
t.references :decidim_consultations_questions, | ||
foreign_key: true, | ||
index: { name: "index_consultations_responses_on_consultation_questions" } | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
..._decidim_consultations_vote_to_decidim_consultations_endorsement.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This migration comes from decidim_consultations (originally 20180129122226) | ||
# frozen_string_literal: true | ||
|
||
class RenameDecidimConsultationsVoteToDecidimConsultationsEndorsement < ActiveRecord::Migration[5.1] | ||
def change | ||
rename_table :decidim_consultations_votes, :decidim_consultations_endorsements | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
...ecidim_consultations_questions_votes_count_to_endorsements_count.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This migration comes from decidim_consultations (originally 20180129122504) | ||
# frozen_string_literal: true | ||
|
||
class RenameDecidimConsultationsQuestionsVotesCountToEndorsementsCount < ActiveRecord::Migration[5.1] | ||
def change | ||
rename_column :decidim_consultations_questions, :votes_count, :endorsements_count | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
...319135738_add_responses_count_to_decidim_consultations_questions.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This migration comes from decidim_consultations (originally 20180130060754) | ||
# frozen_string_literal: true | ||
|
||
class AddResponsesCountToDecidimConsultationsQuestions < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations_questions, :responses_count, :integer, null: false, default: 0 | ||
|
||
reversible do |dir| | ||
dir.up { initialize_counter } | ||
end | ||
end | ||
|
||
def initialize_counter | ||
execute <<-SQL.squish | ||
UPDATE decidim_consultations_questions | ||
SET responses_count = ( | ||
select count(1) | ||
from decidim_consultations_responses | ||
where decidim_consultations_questions_id = decidim_consultations_questions.id | ||
) | ||
SQL | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
db/migrate/20180319135739_rename_vote_related_attributes.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This migration comes from decidim_consultations (originally 20180130110449) | ||
# frozen_string_literal: true | ||
|
||
class RenameVoteRelatedAttributes < ActiveRecord::Migration[5.1] | ||
def change | ||
rename_column :decidim_consultations, :start_voting_date, :start_endorsing_date | ||
rename_column :decidim_consultations, :end_voting_date, :end_endorsing_date | ||
rename_column :decidim_consultations_questions, :external_voting, :external_endorsement | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
..._add_decidim_user_group_id_to_decidim_consultations_endorsements.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This migration comes from decidim_consultations (originally 20180130142018) | ||
# frozen_string_literal: true | ||
|
||
class AddDecidimUserGroupIdToDecidimConsultationsEndorsements < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations_endorsements, :decidim_user_group_id, :integer, index: true | ||
end | ||
end |
37 changes: 37 additions & 0 deletions
37
...igrate/20180319135741_rename_vote_indexes_to_endorsement_indexes.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This migration comes from decidim_consultations (originally 20180130142411) | ||
# frozen_string_literal: true | ||
|
||
class RenameVoteIndexesToEndorsementIndexes < ActiveRecord::Migration[5.1] | ||
def change | ||
rename_index :decidim_consultations_endorsements, | ||
:index_consultations_votes_on_author, | ||
:index_consultations_endorsements_on_author | ||
|
||
rename_index :decidim_consultations_endorsements, | ||
:index_consultations_votes_on_consultation_question, | ||
:index_consultations_endorsements_on_consultation_question | ||
|
||
reversible do |dir| | ||
dir.up { create_authorable_unique } | ||
dir.down { create_author_unique } | ||
end | ||
end | ||
|
||
def create_authorable_unique | ||
remove_index :decidim_consultations_endorsements, name: "index_question_votes_author_unique" | ||
|
||
add_index :decidim_consultations_endorsements, | ||
%w[decidim_consultation_question_id decidim_author_id decidim_user_group_id], | ||
name: "index_question_votes_author_unique", | ||
unique: true | ||
end | ||
|
||
def create_author_unique | ||
remove_index :decidim_consultations_endorsements, name: "index_question_votes_author_unique" | ||
|
||
add_index :decidim_consultations_endorsements, | ||
%w[decidim_consultation_question_id decidim_author_id], | ||
name: "index_question_votes_author_unique", | ||
unique: true | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
...0180319135742_add_response_to_decidim_consultations_endorsements.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This migration comes from decidim_consultations (originally 20180131083844) | ||
# frozen_string_literal: true | ||
|
||
class AddResponseToDecidimConsultationsEndorsements < ActiveRecord::Migration[5.1] | ||
def change | ||
add_reference :decidim_consultations_endorsements, | ||
:decidim_consultations_response, | ||
foreign_key: true, | ||
index: { name: "index_consultations_endorsements_on_consultations_response_id" } | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
db/migrate/20180319135743_rename_endorsement_to_vote.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This migration comes from decidim_consultations (originally 20180201135823) | ||
# frozen_string_literal: true | ||
|
||
class RenameEndorsementToVote < ActiveRecord::Migration[5.1] | ||
def change | ||
rename_table :decidim_consultations_endorsements, :decidim_consultations_votes | ||
rename_column :decidim_consultations_questions, :endorsements_count, :votes_count | ||
rename_column :decidim_consultations, :start_endorsing_date, :start_voting_date | ||
rename_column :decidim_consultations, :end_endorsing_date, :end_voting_date | ||
rename_column :decidim_consultations_questions, :external_endorsement, :external_voting | ||
|
||
rename_index :decidim_consultations_votes, | ||
:index_consultations_endorsements_on_author, | ||
:index_consultations_votes_on_author | ||
|
||
rename_index :decidim_consultations_votes, | ||
:index_consultations_endorsements_on_consultation_question, | ||
:index_consultations_votes_on_consultation_question | ||
|
||
rename_index :decidim_consultations_votes, | ||
:index_consultations_endorsements_on_consultations_response_id, | ||
:index_consultations_votes_on_consultations_response_id | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
.../20180319135744_add_hero_image_to_decidim_consultations_question.decidim_consultations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This migration comes from decidim_consultations (originally 20180202050920) | ||
# frozen_string_literal: true | ||
|
||
class AddHeroImageToDecidimConsultationsQuestion < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :decidim_consultations_questions, :hero_image, :string | ||
remove_column :decidim_consultations_questions, :introductory_video_url, :string | ||
end | ||
end |
Oops, something went wrong.