source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190213141732_update_aggregations_search_last_months_to_version_3.rb | Ruby | mit | 19 | main | 208 | class UpdateAggregationsSearchLastMonthsToVersion3 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_months, version: 3, revert_to_version: 2, materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180921155800_add_index_for_content_list.rb | Ruby | mit | 19 | main | 322 | class AddIndexForContentList < ActiveRecord::Migration[5.2]
def change
# This index is required for the query we run to get the data
# for the /content endpoint. We GROUP_BY these columns.
add_index :dimensions_items, %i[content_uuid base_path title document_type], name: "index_for_content_query"
end
en... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190207143301_add_index_facts_metrics_useful_no.rb | Ruby | mit | 19 | main | 206 | class AddIndexFactsMetricsUsefulNo < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def change
add_index :facts_metrics, %i(dimensions_date_id useful_no), algorithm: :concurrently
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180610081321_add_default_not_null_to_dimensions_items.rb | Ruby | mit | 19 | main | 278 | class AddDefaultNotNullToDimensionsItems < ActiveRecord::Migration[5.1]
def change
change_column_null :dimensions_items, :content_id, false
change_column_null :dimensions_items, :base_path, false
change_column_null :dimensions_items, :schema_name, false
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181211115357_update_aggregations_search_last_three_months_to_version_4.rb | Ruby | mit | 19 | main | 267 | class UpdateAggregationsSearchLastThreeMonthsToVersion4 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_three_months,
version: 4,
revert_to_version: 3,
materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20161123141301_create_content_items.rb | Ruby | mit | 19 | main | 225 | class CreateContentItems < ActiveRecord::Migration[5.0]
def change
create_table :content_items do |t|
t.string :content_id
t.references :organisation, foreign_key: true
t.timestamps
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180928141301_populate_warehouse_item_id.rb | Ruby | mit | 19 | main | 1,068 | class PopulateWarehouseItemId < ActiveRecord::Migration[5.2]
class Dimensions::Item < ActiveRecord::Base
end
def change
multipart_types = %w[travel_advice guide]
say "populating warehouse_item_id from content_id:locale:base_path for guide, travel_advice"
Dimensions::Item.where(document_type: multipa... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180103141736_create_dimensions_items_temps.rb | Ruby | mit | 19 | main | 284 | class CreateDimensionsItemsTemps < ActiveRecord::Migration[5.1]
def change
create_table :dimensions_items_temps, id: false do |t|
t.string :content_id
t.string :title
t.string :link
t.string :description
t.string :organisation_id
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170824145426_drop_organisations.rb | Ruby | mit | 19 | main | 356 | class DropOrganisations < ActiveRecord::Migration[5.1]
def change
drop_table :organisations do |t|
t.string "slug"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "title"
t.string "content_id"
t.index %w[slug], name: "index_organisations_on_sl... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181126120610_update_aggregations_search_last_thirty_days_to_version_2.rb | Ruby | mit | 19 | main | 217 | class UpdateAggregationsSearchLastThirtyDaysToVersion2 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_thirty_days, version: 2, revert_to_version: 1, materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170804092444_add_locale_to_content_items.rb | Ruby | mit | 19 | main | 326 | class AddLocaleToContentItems < ActiveRecord::Migration[5.1]
def up
add_column :content_items, :locale, :string
ActiveRecord::Base.connection.execute("UPDATE content_items SET locale = 'en'")
change_column_null :content_items, :locale, false
end
def down
remove_column :content_items, :locale
en... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180626085042_create_publishing_api_events.rb | Ruby | mit | 19 | main | 211 | class CreatePublishingApiEvents < ActiveRecord::Migration[5.1]
def change
create_table :publishing_api_events do |t|
t.string :routing_key
t.json :payload
t.timestamps
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180219151742_add_metadata_fields_to_dimensions_item.rb | Ruby | mit | 19 | main | 351 | class AddMetadataFieldsToDimensionsItem < ActiveRecord::Migration[5.1]
def change
add_column :dimensions_items, :document_type, :string
add_column :dimensions_items, :content_purpose_supertype, :string
add_column :dimensions_items, :first_published_at, :datetime
add_column :dimensions_items, :public_u... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190104120051_add_not_null_constraint_and_index_to_document_types.rb | Ruby | mit | 19 | main | 222 | class AddNotNullConstraintAndIndexToDocumentTypes < ActiveRecord::Migration[5.2]
def change
change_column_null :dimensions_editions, :document_type, false
add_index :dimensions_editions, :document_type
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190603145828_update_aggregations_search_last_thirty_days_to_version_10.rb | Ruby | mit | 19 | main | 251 | class UpdateAggregationsSearchLastThirtyDaysToVersion10 < ActiveRecord::Migration[5.2]
def change
update_view(
:aggregations_search_last_thirty_days,
version: 10,
revert_to_version: 9,
materialized: true,
)
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170626133926_create_report_rows.rb | Ruby | mit | 19 | main | 223 | class CreateReportRows < ActiveRecord::Migration[5.1]
def change
create_table :report_rows do |t|
t.string :content_id
t.json :data
end
add_index :report_rows, :content_id, unique: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190213141743_update_aggregations_search_last_three_months_to_version_5.rb | Ruby | mit | 19 | main | 219 | class UpdateAggregationsSearchLastThreeMonthsToVersion5 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_three_months, version: 5, revert_to_version: 4, materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190612150721_add_parent_id_to_dimension_edition.rb | Ruby | mit | 19 | main | 245 | class AddParentIdToDimensionEdition < ActiveRecord::Migration[5.2]
def change
add_column :dimensions_editions, :parent_id, :integer, null: true
add_index :dimensions_editions, :parent_id, name: "index_dim_edition_parent_id"
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180610081625_update_indexes_dimensions_items.rb | Ruby | mit | 19 | main | 388 | class UpdateIndexesDimensionsItems < ActiveRecord::Migration[5.1]
def change
remove_index :dimensions_items, %i(latest base_path)
add_index :dimensions_items, %i(base_path latest), unique: true, where: "latest = 'true'"
remove_index :dimensions_items, name: "index_dimensions_items_on_latest_and_content_i... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190213141753_update_aggregations_search_last_six_months_to_version_5.rb | Ruby | mit | 19 | main | 215 | class UpdateAggregationsSearchLastSixMonthsToVersion5 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_six_months, version: 5, revert_to_version: 4, materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181004120457_rename_facts_metrics_dimensions_item_id_to_dimensions_edition_id.rb | Ruby | mit | 19 | main | 284 | class RenameFactsMetricsDimensionsItemIdToDimensionsEditionId < ActiveRecord::Migration[5.2]
def change
rename_column :facts_metrics, :dimensions_item_id, :dimensions_edition_id
rename_index :facts_metrics, "metrics_item_id_date_id", "metrics_edition_id_date_id"
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180118133918_drop_taxonomy_todos.rb | Ruby | mit | 19 | main | 328 | class DropTaxonomyTodos < ActiveRecord::Migration[5.1]
def change
drop_table :taxonomy_todos do |t|
t.bigint "content_item_id"
t.bigint "taxonomy_project_id"
t.datetime "completed_at"
t.string "completed_by"
t.string "status", default: "todo"
t.timestamps null: false
end
... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180119150347_drop_questions.rb | Ruby | mit | 19 | main | 214 | class DropQuestions < ActiveRecord::Migration[5.1]
def change
drop_table :questions do |t|
t.string "type", null: false
t.text "text", null: false
t.timestamps null: false
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180119144707_drop_allocations.rb | Ruby | mit | 19 | main | 225 | class DropAllocations < ActiveRecord::Migration[5.1]
def change
drop_table :allocations do |t|
t.string "content_id", null: false
t.string "uid", null: false
t.timestamps null: false
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190213155931_add_indexes_view_aggregations_search_last_six_months.rb | Ruby | mit | 19 | main | 1,361 | class AddIndexesViewAggregationsSearchLastSixMonths < ActiveRecord::Migration[5.2]
def up
execute "create index aggregations_search_last_six_months_gin_base_path on aggregations_search_last_six_months using gin(to_tsvector('english'::regconfig, replace((base_path)::text, '/'::text, ' '::text)))"
execute "crea... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180105112615_add_index_to_items_dimension.rb | Ruby | mit | 19 | main | 308 | class AddIndexToItemsDimension < ActiveRecord::Migration[5.1]
def change
add_index :dimensions_items, %i[content_id link organisation_id], name: :dimensions_items_natural_key
add_index :dimensions_items_temps, %i[content_id link organisation_id], name: :dimensions_items_temps_natual_key
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181031124930_create_aggregations_monthly_metrics.rb | Ruby | mit | 19 | main | 1,099 | class CreateAggregationsMonthlyMetrics < ActiveRecord::Migration[5.2]
def change
create_table :aggregations_monthly_metrics do |t|
t.string :dimensions_month_id, null: false
t.references :dimensions_edition, null: false
t.integer :pviews, null: false, default: 0
t.integer :upviews, null: ... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190312140803_update_aggregations_search_last_thirty_days_to_version_8.rb | Ruby | mit | 19 | main | 265 | class UpdateAggregationsSearchLastThirtyDaysToVersion8 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_thirty_days,
version: 8,
revert_to_version: 7,
materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190312141431_update_aggregations_search_last_three_months_to_version_8.rb | Ruby | mit | 19 | main | 267 | class UpdateAggregationsSearchLastThreeMonthsToVersion8 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_three_months,
version: 8,
revert_to_version: 7,
materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190213162703_add_unique_indexes_view_aggregations_search_views.rb | Ruby | mit | 19 | main | 768 | class AddUniqueIndexesViewAggregationsSearchViews < ActiveRecord::Migration[5.2]
def change
add_index :aggregations_search_last_thirty_days, :warehouse_item_id, unique: true, name: :aggregations_search_last_thirty_days_pk
add_index :aggregations_search_last_months, :warehouse_item_id, unique: true, name: :agg... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181211115100_update_aggregations_search_last_months_to_version_2.rb | Ruby | mit | 19 | main | 256 | class UpdateAggregationsSearchLastMonthsToVersion2 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_months,
version: 2,
revert_to_version: 1,
materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190603145838_update_aggregations_search_last_three_months_to_version_10.rb | Ruby | mit | 19 | main | 253 | class UpdateAggregationsSearchLastThreeMonthsToVersion10 < ActiveRecord::Migration[5.2]
def change
update_view(
:aggregations_search_last_three_months,
version: 10,
revert_to_version: 9,
materialized: true,
)
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190220161718_change_upviews_and_warehouse_item_id_indexes.rb | Ruby | mit | 19 | main | 1,244 | class ChangeUpviewsAndWarehouseItemIdIndexes < ActiveRecord::Migration[5.2]
def change
remove_index :aggregations_search_last_twelve_months, name: :search_last_twelve_months_upviews
remove_index :aggregations_search_last_six_months, name: :search_last_six_months_upviews
remove_index :aggregations_search_l... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190604105034_create_lower_index_on_base_path.rb | Ruby | mit | 19 | main | 275 | class CreateLowerIndexOnBasePath < ActiveRecord::Migration[5.2]
def up
execute <<-SQL
CREATE INDEX index_lower_base_path ON dimensions_editions (lower(base_path));
SQL
end
def down
execute <<-SQL
DROP INDEX index_lower_base_path;
SQL
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170314110425_create_join_table_content_item_taxonomy.rb | Ruby | mit | 19 | main | 292 | class CreateJoinTableContentItemTaxonomy < ActiveRecord::Migration[5.0]
def change
create_join_table :content_items, :taxonomies do |t|
t.index [:content_item_id]
t.index %i[taxonomy_id content_item_id], name: "index_content_item_taxonomies", unique: true
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180608125059_remove_default_values_for_locale_in_items.rb | Ruby | mit | 19 | main | 221 | class RemoveDefaultValuesForLocaleInItems < ActiveRecord::Migration[5.1]
def change
change_column(:dimensions_items, :locale, :string, null: true)
change_column_default :dimensions_items, :locale, nil
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170518123000_create_questions.rb | Ruby | mit | 19 | main | 238 | class CreateQuestions < ActiveRecord::Migration[5.0]
def change
create_table :questions do |t|
t.string :type, null: false
t.text :text, null: false
t.timestamps
end
add_index :questions, :type
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181211114147_update_aggregations_search_last_thirty_days_to_version_4.rb | Ruby | mit | 19 | main | 217 | class UpdateAggregationsSearchLastThirtyDaysToVersion4 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_thirty_days, version: 4, revert_to_version: 3, materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170518125955_create_responses.rb | Ruby | mit | 19 | main | 214 | class CreateResponses < ActiveRecord::Migration[5.0]
def change
create_table :responses do |t|
t.belongs_to :audit
t.belongs_to :question
t.text :value
t.timestamps
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181004115155_rename_fact_edition_dimensions_item_id_to_dimensions_edition_id.rb | Ruby | mit | 19 | main | 293 | class RenameFactEditionDimensionsItemIdToDimensionsEditionId < ActiveRecord::Migration[5.2]
def change
rename_column :facts_editions, :dimensions_item_id, :dimensions_edition_id
rename_index :facts_editions, "editions_item_id_date_id", "facts_editions_edition_id_date_id"
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190603145901_update_aggregations_search_last_six_months_to_version_10.rb | Ruby | mit | 19 | main | 249 | class UpdateAggregationsSearchLastSixMonthsToVersion10 < ActiveRecord::Migration[5.2]
def change
update_view(
:aggregations_search_last_six_months,
version: 10,
revert_to_version: 9,
materialized: true,
)
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180425100640_remove_outdated_from_items.rb | Ruby | mit | 19 | main | 202 | class RemoveOutdatedFromItems < ActiveRecord::Migration[5.1]
def change
remove_column :dimensions_items, :outdated, :boolean
remove_column :dimensions_items, :outdated_at, :datetime
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180315144816_rename_number_of_issues_to_feedex_comments.rb | Ruby | mit | 19 | main | 239 | class RenameNumberOfIssuesToFeedexComments < ActiveRecord::Migration[5.1]
def change
rename_column :facts_metrics, :number_of_issues, :feedex_comments
rename_column :events_feedexes, :number_of_issues, :feedex_comments
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190312141439_update_aggregations_search_last_twelve_months_to_version_8.rb | Ruby | mit | 19 | main | 269 | class UpdateAggregationsSearchLastTwelveMonthsToVersion8 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_twelve_months,
version: 8,
revert_to_version: 7,
materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180425132405_process_name_is_not_null.rb | Ruby | mit | 19 | main | 318 | class ProcessNameIsNotNull < ActiveRecord::Migration[5.1]
def up
Events::GA.update_all(process_name: 1)
change_column :events_gas, :process_name, :integer, null: false
end
def down
change_column :events_gas, :process_name, :integer, null: true
Events::GA.update_all(process_name: nil)
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180210123458_create_events_gas.rb | Ruby | mit | 19 | main | 279 | class CreateEventsGas < ActiveRecord::Migration[5.1]
def change
create_table :events_gas do |t|
t.date :date
t.string :page_path
t.integer :pageviews
t.integer :unique_pageviews
t.timestamps
t.index %w[page_path date]
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181126152658_update_aggregations_search_last_twelve_months_to_version_2.rb | Ruby | mit | 19 | main | 221 | class UpdateAggregationsSearchLastTwelveMonthsToVersion2 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_twelve_months, version: 2, revert_to_version: 1, materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181122105601_add_full_text_index_base_path.rb | Ruby | mit | 19 | main | 329 | class AddFullTextIndexBasePath < ActiveRecord::Migration[5.2]
def up
execute "create index dimensions_editions_base_path on dimensions_editions using gin(to_tsvector('english'::regconfig, replace((base_path)::text, '/'::text, ' '::text)))"
end
def down
execute "drop index dimensions_editions_base_path"
... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181205165620_update_aggregations_search_last_three_months_to_version_3.rb | Ruby | mit | 19 | main | 219 | class UpdateAggregationsSearchLastThreeMonthsToVersion3 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_three_months, version: 3, revert_to_version: 2, materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180418135558_add_is_this_useful_columns_to_events_gas.rb | Ruby | mit | 19 | main | 233 | class AddIsThisUsefulColumnsToEventsGas < ActiveRecord::Migration[5.1]
def change
add_column :events_gas, :is_this_useful_yes, :integer, default: 0
add_column :events_gas, :is_this_useful_no, :integer, default: 0
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180309144813_add_index_dimensions_items_organisation.rb | Ruby | mit | 19 | main | 239 | class AddIndexDimensionsItemsOrganisation < ActiveRecord::Migration[5.1]
def change
add_index :dimensions_items, :primary_organisation_content_id,
name: :index_dimensions_items_primary_organisation_content_id
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180119150908_drop_responses.rb | Ruby | mit | 19 | main | 224 | class DropResponses < ActiveRecord::Migration[5.1]
def change
drop_table :responses do |t|
t.integer "audit_id"
t.integer "question_id"
t.text "value"
t.timestamps null: false
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181001174718_rename_facts_edition_columns.rb | Ruby | mit | 19 | main | 462 | class RenameFactsEditionColumns < ActiveRecord::Migration[5.2]
def change
rename_column :facts_editions, :number_of_pdfs, :pdf_count
rename_column :facts_editions, :number_of_word_files, :doc_count
rename_column :facts_editions, :readability_score, :readability
rename_column :facts_editions, :string_l... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170912052917_drop_subthemes.rb | Ruby | mit | 19 | main | 352 | class DropSubthemes < ActiveRecord::Migration[5.1]
def change
drop_table :subthemes do |t|
t.bigint "theme_id"
t.string "name", null: false
t.timestamps
t.index %w[theme_id name], name: "index_subthemes_on_theme_id_and_name", unique: true
t.index %w[theme_id], name: "index_subthemes... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180926100046_rename_content_uuid_to_warehouse_item_id.rb | Ruby | mit | 19 | main | 417 | class RenameContentUuidToWarehouseItemId < ActiveRecord::Migration[5.2]
def change
rename_column :dimensions_items, :content_uuid, :warehouse_item_id
rename_index :dimensions_items, "index_dimensions_items_content_uuid_latest", "index_dimensions_items_warehouse_item_id_latest"
rename_index :dimensions_it... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190603083348_update_aggregations_search_last_months_to_version_7.rb | Ruby | mit | 19 | main | 240 | class UpdateAggregationsSearchLastMonthsToVersion7 < ActiveRecord::Migration[5.2]
def change
update_view(
:aggregations_search_last_months,
version: 7,
revert_to_version: 6,
materialized: true,
)
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170515134126_create_users.rb | Ruby | mit | 19 | main | 404 | class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :uid
t.string :organisation_slug
t.string :organisation_content_id
t.text :permissions
t.boolean :remotely_signed_out, default: fa... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190207143313_add_index_facts_metrics_useful_feedex.rb | Ruby | mit | 19 | main | 207 | class AddIndexFactsMetricsUsefulFeedex < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def change
add_index :facts_metrics, %i(dimensions_date_id feedex), algorithm: :concurrently
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181122152546_remove_default_zeros_from_aggregations_monthly_metrics.rb | Ruby | mit | 19 | main | 568 | class RemoveDefaultZerosFromAggregationsMonthlyMetrics < ActiveRecord::Migration[5.2]
COLS = %i[pviews upviews feedex searches exits entrances bounces bounce_rate avg_page_time page_time].freeze
def up
COLS.each do |col|
change_column_default(:aggregations_monthly_metrics, col, nil)
change_column_n... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20171207164824_add_foreign_keys_to_allocations.rb | Ruby | mit | 19 | main | 305 | class AddForeignKeysToAllocations < ActiveRecord::Migration[5.1]
def change
add_index "users", :uid, unique: true
add_foreign_key "allocations", "content_items", column: :content_id, primary_key: :content_id
add_foreign_key "allocations", "users", column: :uid, primary_key: :uid
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180801075913_add_bounces_and_time_on_page_to_events_gas_and_facts_metrics.rb | Ruby | mit | 19 | main | 362 | class AddBouncesAndTimeOnPageToEventsGasAndFactsMetrics < ActiveRecord::Migration[5.1]
def change
add_column :events_gas, :bounces, :integer, default: 0
add_column :events_gas, :time_on_page, :integer, default: 0
add_column :facts_metrics, :bounces, :integer, default: 0
add_column :facts_metrics, :tim... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190311164541_update_aggregations_search_last_months_to_version_5.rb | Ruby | mit | 19 | main | 256 | class UpdateAggregationsSearchLastMonthsToVersion5 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_months,
version: 5,
revert_to_version: 4,
materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170808081001_add_qualitative_measures_to_audits.rb | Ruby | mit | 19 | main | 553 | class AddQualitativeMeasuresToAudits < ActiveRecord::Migration[5.1]
def change
add_column :audits, :change_title, :boolean
add_column :audits, :change_description, :boolean
add_column :audits, :change_body, :boolean
add_column :audits, :change_attachments, :boolean
add_column :audits, :outdated, :... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190311164340_update_aggregations_search_last_three_months_to_version_7.rb | Ruby | mit | 19 | main | 267 | class UpdateAggregationsSearchLastThreeMonthsToVersion7 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_three_months,
version: 7,
revert_to_version: 6,
materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190204102543_remove_content_supergroups_and_subgroups.rb | Ruby | mit | 19 | main | 231 | class RemoveContentSupergroupsAndSubgroups < ActiveRecord::Migration[5.2]
def change
remove_column :dimensions_editions, :content_purpose_supergroup
remove_column :dimensions_editions, :content_purpose_subgroup
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180610074451_add_not_null_constratint_to_facts_metrics.rb | Ruby | mit | 19 | main | 228 | class AddNotNullConstratintToFactsMetrics < ActiveRecord::Migration[5.1]
def change
change_column_null :facts_metrics, :dimensions_item_id, false
change_column_null :facts_metrics, :dimensions_date_id, false
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181030120956_add_withdrawn_and_historical_constraints.rb | Ruby | mit | 19 | main | 294 | class AddWithdrawnAndHistoricalConstraints < ActiveRecord::Migration[5.2]
def up
say "Updating withdrawn for all editions"
Dimensions::Edition.update_all(withdrawn: false)
say "Updating historical for all editions"
Dimensions::Edition.update_all(historical: false)
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181001125635_rename_facts_metrics_columns.rb | Ruby | mit | 19 | main | 665 | class RenameFactsMetricsColumns < ActiveRecord::Migration[5.2]
def change
rename_column :facts_metrics, :pageviews, :pviews
rename_column :facts_metrics, :unique_pageviews, :upviews
rename_column :facts_metrics, :is_this_useful_yes, :useful_yes
rename_column :facts_metrics, :is_this_useful_no, :useful... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190204171432_update_reading_time.rb | Ruby | mit | 19 | main | 579 | class UpdateReadingTime < ActiveRecord::Migration[5.2]
class Facts::Edition < ApplicationRecord
end
class Dimensions::Edition < ApplicationRecord
has_one :facts_edition, class_name: "Facts::Edition", foreign_key: :dimensions_edition_id
end
def up
Dimensions::Edition.where(latest: true).find_each do ... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180610075700_add_unique_index_to_facts_editions.rb | Ruby | mit | 19 | main | 318 | class AddUniqueIndexToFactsEditions < ActiveRecord::Migration[5.1]
def change
remove_index :facts_editions, :dimensions_item_id
remove_index :facts_editions, :dimensions_date_id
add_index :facts_editions, %i[dimensions_item_id dimensions_date_id], name: :editions_item_id_date_id, unique: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170606163951_create_taxonomy_todos.rb | Ruby | mit | 19 | main | 316 | class CreateTaxonomyTodos < ActiveRecord::Migration[5.1]
def change
create_table :taxonomy_todos do |t|
t.belongs_to :content_item, foreign_key: true
t.belongs_to :taxonomy_project, foreign_key: true
t.datetime :completed_at
t.string :completed_by
t.timestamps
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180223142258_create_events_feedexes.rb | Ruby | mit | 19 | main | 242 | class CreateEventsFeedexes < ActiveRecord::Migration[5.1]
def change
create_table :events_feedexes do |t|
t.date :date
t.string :page_path
t.integer :number_of_issues
t.index %w[page_path date]
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190117123913_remove_bounce_rate.rb | Ruby | mit | 19 | main | 230 | class RemoveBounceRate < ActiveRecord::Migration[5.2]
def change
remove_column :aggregations_monthly_metrics, :bounce_rate
remove_column :events_gas, :bounce_rate
remove_column :facts_metrics, :bounce_rate
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180305161014_add_odyssey_metrics.rb | Ruby | mit | 19 | main | 289 | class AddOdysseyMetrics < ActiveRecord::Migration[5.1]
def change
add_column :dimensions_items, :string_length, :integer, default: 0
add_column :dimensions_items, :sentence_count, :integer, default: 0
add_column :dimensions_items, :word_count, :integer, default: 0
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180610073937_add_not_null_constratint_to_facts_editions.rb | Ruby | mit | 19 | main | 231 | class AddNotNullConstratintToFactsEditions < ActiveRecord::Migration[5.1]
def change
change_column_null :facts_editions, :dimensions_item_id, false
change_column_null :facts_editions, :dimensions_date_id, false
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170605161124_rename_taxonomies_to_taxons.rb | Ruby | mit | 19 | main | 254 | class RenameTaxonomiesToTaxons < ActiveRecord::Migration[5.1]
def change
rename_table :taxonomies, :taxons
rename_table :content_items_taxonomies, :content_items_taxons
rename_column :content_items_taxons, :taxonomy_id, :taxon_id
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170810074052_create_allocations.rb | Ruby | mit | 19 | main | 304 | class CreateAllocations < ActiveRecord::Migration[5.1]
def change
create_table :allocations do |t|
t.string :content_id, null: false
t.string :uid, null: false
t.timestamps
end
add_index :allocations, :content_id, unique: true
add_index :allocations, :uid
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170607101716_create_themes.rb | Ruby | mit | 19 | main | 210 | class CreateThemes < ActiveRecord::Migration[5.1]
def change
create_table :themes do |t|
t.string :name, null: false
t.timestamps
end
add_index :themes, :name, unique: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180718161302_remove_publishing_api_events.rb | Ruby | mit | 19 | main | 291 | class RemovePublishingApiEvents < ActiveRecord::Migration[5.1]
def change
remove_reference :dimensions_items, :publishing_api_event, foreign_key: true
drop_table :publishing_api_events do |t|
t.string :routing_key
t.json :payload
t.timestamps
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180322140016_add_indexes_for_master_process.rb | Ruby | mit | 19 | main | 256 | class AddIndexesForMasterProcess < ActiveRecord::Migration[5.1]
def change
add_index :dimensions_items, %i[latest content_id]
add_index :facts_metrics, %i[dimensions_date_id dimensions_item_id], name: "index_facts_metrics_date_item_id"
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181106170339_create_aggregations_search_last_three_months.rb | Ruby | mit | 19 | main | 218 | class CreateAggregationsSearchLastThreeMonths < ActiveRecord::Migration[5.2]
def change
Aggregations::MaterializedView.prepare
create_view :aggregations_search_last_three_months, materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190603145851_update_aggregations_search_last_twelve_months_to_version_10.rb | Ruby | mit | 19 | main | 255 | class UpdateAggregationsSearchLastTwelveMonthsToVersion10 < ActiveRecord::Migration[5.2]
def change
update_view(
:aggregations_search_last_twelve_months,
version: 10,
revert_to_version: 9,
materialized: true,
)
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181126095403_recreate_publishing_api_events.rb | Ruby | mit | 19 | main | 309 | class RecreatePublishingApiEvents < ActiveRecord::Migration[5.2]
def change
create_table :publishing_api_events do |t|
t.string :routing_key
t.jsonb :payload
t.timestamps
end
add_reference :dimensions_editions, :publishing_api_event, foreign_key: true, index: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20171220091851_create_dimensions_dates.rb | Ruby | mit | 19 | main | 852 | class CreateDimensionsDates < ActiveRecord::Migration[5.1]
def change
create_table :dimensions_dates, id: :date, primary_key: :date do |t|
t.string :date_name, index: true, null: false
t.string :date_name_abbreviated, index: true, null: false
t.integer :year, null: false
t.integer :quarter... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170607102042_create_inventory_rules.rb | Ruby | mit | 19 | main | 442 | class CreateInventoryRules < ActiveRecord::Migration[5.1]
def change
create_table :inventory_rules do |t|
t.belongs_to :subtheme
t.string :link_type, null: false
t.string :target_content_id, null: false
t.timestamps
end
add_index :inventory_rules,
%i(subtheme_id link... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170824142643_drop_groups.rb | Ruby | mit | 19 | main | 262 | class DropGroups < ActiveRecord::Migration[5.1]
def change
drop_table :groups do |t|
t.string :slug
t.string :name
t.string :group_type
t.integer :parent_group_id, foreign_key: true, null: true
t.timestamps
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190116142924_remove_content_purpose_document_supertype_column_from_dimensions_editions.rb | Ruby | mit | 19 | main | 211 | class RemoveContentPurposeDocumentSupertypeColumnFromDimensionsEditions < ActiveRecord::Migration[5.2]
def change
remove_column :dimensions_editions, :content_purpose_document_supertype, :string
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181025135539_remove_duplicated_base_paths_metrics.rb | Ruby | mit | 19 | main | 847 | class RemoveDuplicatedBasePathsMetrics < ActiveRecord::Migration[5.2]
def up
loop do
say "------> Deleting batch of duplications"
total = clean_up_duplicated_metrics!
break if total.zero?
end
end
private
def clean_up_duplicated_metrics!
edition_ids = Dimensions::Edition.
sele... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181009133439_add_index_for_organisation_list.rb | Ruby | mit | 19 | main | 254 | class AddIndexForOrganisationList < ActiveRecord::Migration[5.2]
def change
add_index :dimensions_editions, %i[latest organisation_id primary_organisation_title],
name: "index_dimensions_editions_on_latest_org_id_org_title"
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190603080748_rename_dimensions_edition_organisation_id.rb | Ruby | mit | 19 | main | 278 | class RenameDimensionsEditionOrganisationId < ActiveRecord::Migration[5.2]
def up
rename_column :dimensions_editions, :organisation_id, :primary_organisation_id
end
def down
rename_column :dimensions_editions, :primary_organisation_id, :organisation_id
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180928150637_add_not_null_constraint_to_warehouse_item_id.rb | Ruby | mit | 19 | main | 227 | class AddNotNullConstraintToWarehouseItemId < ActiveRecord::Migration[5.2]
def change
say "setting not null constraint on `warehouse_item_id`"
change_column_null :dimensions_items, :warehouse_item_id, false
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20170912052927_drop_themes.rb | Ruby | mit | 19 | main | 231 | class DropThemes < ActiveRecord::Migration[5.1]
def change
drop_table :themes do |t|
t.string "name", null: false
t.timestamps
t.index %w[name], name: "index_themes_on_name", unique: true
end
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190603083456_update_aggregations_search_last_thirty_days_to_version_9.rb | Ruby | mit | 19 | main | 249 | class UpdateAggregationsSearchLastThirtyDaysToVersion9 < ActiveRecord::Migration[5.2]
def change
update_view(
:aggregations_search_last_thirty_days,
version: 9,
revert_to_version: 8,
materialized: true,
)
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180309144816_remove_content_items.rb | Ruby | mit | 19 | main | 555 | class RemoveContentItems < ActiveRecord::Migration[5.1]
def change
drop_table :content_items do |t|
t.string :content_id
t.datetime :public_updated_at
t.string :base_path
t.string :title
t.string :document_type
t.string :description
t.integer :one_month_page_views, defaul... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180119145749_drop_audits.rb | Ruby | mit | 19 | main | 536 | class DropAudits < ActiveRecord::Migration[5.1]
def change
drop_table :audits do |t|
t.string "content_id", null: false
t.string "uid", null: false
t.boolean "change_title"
t.boolean "change_description"
t.boolean "change_body"
t.boolean "change_attachments"
t.boolean "ou... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181122134132_remove_default_zeros_from_facts_metrics.rb | Ruby | mit | 19 | main | 389 | class RemoveDefaultZerosFromFactsMetrics < ActiveRecord::Migration[5.2]
COLS = %i[pviews upviews searches feedex exits entrances bounces bounce_rate avg_page_time page_time].freeze
def up
COLS.each do |col|
change_column_default(:facts_metrics, col, nil)
end
end
def down
COLS.each do |col|
... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20180824105759_delete_old_edition_metrics.rb | Ruby | mit | 19 | main | 572 | class DeleteOldEditionMetrics < ActiveRecord::Migration[5.2]
def change
remove_column :facts_editions, :contractions_count
remove_column :facts_editions, :equality_count
remove_column :facts_editions, :indefinite_article_count
remove_column :facts_editions, :passive_count
remove_column :facts_edit... |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181126151050_update_aggregations_search_last_three_months_to_version_2.rb | Ruby | mit | 19 | main | 219 | class UpdateAggregationsSearchLastThreeMonthsToVersion2 < ActiveRecord::Migration[5.2]
def change
update_view :aggregations_search_last_three_months, version: 2, revert_to_version: 1, materialized: true
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20190603083643_update_aggregations_search_last_six_months_to_version_9.rb | Ruby | mit | 19 | main | 247 | class UpdateAggregationsSearchLastSixMonthsToVersion9 < ActiveRecord::Migration[5.2]
def change
update_view(
:aggregations_search_last_six_months,
version: 9,
revert_to_version: 8,
materialized: true,
)
end
end |
github | alphagov/content-data-api | https://github.com/alphagov/content-data-api | db/migrate/20181106121337_add_index_to_last_month_aggregations.rb | Ruby | mit | 19 | main | 222 | class AddIndexToLastMonthAggregations < ActiveRecord::Migration[5.2]
def change
add_index :aggregations_search_last_months, %w(dimensions_edition_id upviews), name: "index_on_last_month_edition_id_upviews"
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.