diff options
author | Starfall <root@starfall.blue> | 2019-12-09 19:07:33 -0600 |
---|---|---|
committer | Starfall <root@starfall.blue> | 2019-12-09 19:09:31 -0600 |
commit | 6b34fcfef7566105e8d80ab5fee0a539c06cddbf (patch) | |
tree | 8fad2d47bf8be255d3c671c40cbfd04c2f55ed03 /db/migrate | |
parent | 9fbb4af7611aa7836e65ef9f544d341423c15685 (diff) | |
parent | 246addd5b33a172600342af3fb6fb5e4c80ad95e (diff) |
Merge branch 'glitch'`
Diffstat (limited to 'db/migrate')
30 files changed, 375 insertions, 70 deletions
diff --git a/db/migrate/20161202132159_add_in_reply_to_account_id_to_statuses.rb b/db/migrate/20161202132159_add_in_reply_to_account_id_to_statuses.rb index 2c24b53d0..3a559ccd6 100644 --- a/db/migrate/20161202132159_add_in_reply_to_account_id_to_statuses.rb +++ b/db/migrate/20161202132159_add_in_reply_to_account_id_to_statuses.rb @@ -3,7 +3,7 @@ class AddInReplyToAccountIdToStatuses < ActiveRecord::Migration[5.0] add_column :statuses, :in_reply_to_account_id, :integer, null: true, default: nil ActiveRecord::Base.transaction do - Status.where.not(in_reply_to_id: nil).includes(:thread).find_each do |status| + Status.unscoped.where.not(in_reply_to_id: nil).includes(:thread).find_each do |status| next if status.thread.nil? status.in_reply_to_account_id = status.thread.account_id diff --git a/db/migrate/20170209184350_add_reply_to_statuses.rb b/db/migrate/20170209184350_add_reply_to_statuses.rb index c5074728b..b8b5c1306 100644 --- a/db/migrate/20170209184350_add_reply_to_statuses.rb +++ b/db/migrate/20170209184350_add_reply_to_statuses.rb @@ -1,7 +1,7 @@ class AddReplyToStatuses < ActiveRecord::Migration[5.0] def up add_column :statuses, :reply, :boolean, nil: false, default: false - Status.update_all('reply = (in_reply_to_id IS NOT NULL)') + Status.unscoped.update_all('reply = (in_reply_to_id IS NOT NULL)') end def down diff --git a/db/migrate/20170918125918_ids_to_bigints.rb b/db/migrate/20170918125918_ids_to_bigints.rb index c6feed8f9..8e19468db 100644 --- a/db/migrate/20170918125918_ids_to_bigints.rb +++ b/db/migrate/20170918125918_ids_to_bigints.rb @@ -5,70 +5,70 @@ class IdsToBigints < ActiveRecord::Migration[5.1] disable_ddl_transaction! - INCLUDED_COLUMNS = [ - [:account_domain_blocks, :account_id], - [:account_domain_blocks, :id], - [:accounts, :id], - [:blocks, :account_id], - [:blocks, :id], - [:blocks, :target_account_id], - [:conversation_mutes, :account_id], - [:conversation_mutes, :id], - [:domain_blocks, :id], - [:favourites, :account_id], - [:favourites, :id], - [:favourites, :status_id], - [:follow_requests, :account_id], - [:follow_requests, :id], - [:follow_requests, :target_account_id], - [:follows, :account_id], - [:follows, :id], - [:follows, :target_account_id], - [:imports, :account_id], - [:imports, :id], - [:media_attachments, :account_id], - [:media_attachments, :id], - [:mentions, :account_id], - [:mentions, :id], - [:mutes, :account_id], - [:mutes, :id], - [:mutes, :target_account_id], - [:notifications, :account_id], - [:notifications, :from_account_id], - [:notifications, :id], - [:oauth_access_grants, :application_id], - [:oauth_access_grants, :id], - [:oauth_access_grants, :resource_owner_id], - [:oauth_access_tokens, :application_id], - [:oauth_access_tokens, :id], - [:oauth_access_tokens, :resource_owner_id], - [:oauth_applications, :id], - [:oauth_applications, :owner_id], - [:reports, :account_id], - [:reports, :action_taken_by_account_id], - [:reports, :id], - [:reports, :target_account_id], - [:session_activations, :access_token_id], - [:session_activations, :user_id], - [:session_activations, :web_push_subscription_id], - [:settings, :id], - [:settings, :thing_id], - [:statuses, :account_id], - [:statuses, :application_id], - [:statuses, :in_reply_to_account_id], - [:stream_entries, :account_id], - [:stream_entries, :id], - [:subscriptions, :account_id], - [:subscriptions, :id], - [:tags, :id], - [:users, :account_id], - [:users, :id], - [:web_settings, :id], - [:web_settings, :user_id], - ] - INCLUDED_COLUMNS << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards) - def migrate_columns(to_type) + included_columns = [ + [:account_domain_blocks, :account_id], + [:account_domain_blocks, :id], + [:accounts, :id], + [:blocks, :account_id], + [:blocks, :id], + [:blocks, :target_account_id], + [:conversation_mutes, :account_id], + [:conversation_mutes, :id], + [:domain_blocks, :id], + [:favourites, :account_id], + [:favourites, :id], + [:favourites, :status_id], + [:follow_requests, :account_id], + [:follow_requests, :id], + [:follow_requests, :target_account_id], + [:follows, :account_id], + [:follows, :id], + [:follows, :target_account_id], + [:imports, :account_id], + [:imports, :id], + [:media_attachments, :account_id], + [:media_attachments, :id], + [:mentions, :account_id], + [:mentions, :id], + [:mutes, :account_id], + [:mutes, :id], + [:mutes, :target_account_id], + [:notifications, :account_id], + [:notifications, :from_account_id], + [:notifications, :id], + [:oauth_access_grants, :application_id], + [:oauth_access_grants, :id], + [:oauth_access_grants, :resource_owner_id], + [:oauth_access_tokens, :application_id], + [:oauth_access_tokens, :id], + [:oauth_access_tokens, :resource_owner_id], + [:oauth_applications, :id], + [:oauth_applications, :owner_id], + [:reports, :account_id], + [:reports, :action_taken_by_account_id], + [:reports, :id], + [:reports, :target_account_id], + [:session_activations, :access_token_id], + [:session_activations, :user_id], + [:session_activations, :web_push_subscription_id], + [:settings, :id], + [:settings, :thing_id], + [:statuses, :account_id], + [:statuses, :application_id], + [:statuses, :in_reply_to_account_id], + [:stream_entries, :account_id], + [:stream_entries, :id], + [:subscriptions, :account_id], + [:subscriptions, :id], + [:tags, :id], + [:users, :account_id], + [:users, :id], + [:web_settings, :id], + [:web_settings, :user_id], + ] + included_columns << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards) + # Print out a warning that this will probably take a while. say '' say 'WARNING: This migration may take a *long* time for large instances' @@ -86,7 +86,7 @@ class IdsToBigints < ActiveRecord::Migration[5.1] sleep 1 end - tables = INCLUDED_COLUMNS.map(&:first).uniq + tables = included_columns.map(&:first).uniq table_sizes = {} # Sort tables by their size @@ -94,7 +94,7 @@ class IdsToBigints < ActiveRecord::Migration[5.1] table_sizes[table] = estimate_rows_in_table(table) end - ordered_columns = INCLUDED_COLUMNS.sort_by do |col_parts| + ordered_columns = included_columns.sort_by do |col_parts| [-table_sizes[col_parts.first], col_parts.last] end diff --git a/db/migrate/20180410220657_create_bookmarks.rb b/db/migrate/20180410220657_create_bookmarks.rb index 08d22c10d..bc79022e4 100644 --- a/db/migrate/20180410220657_create_bookmarks.rb +++ b/db/migrate/20180410220657_create_bookmarks.rb @@ -1,3 +1,6 @@ +# This migration is a duplicate of 20180831171112 and may get ignored, see +# config/initializers/0_duplicate_migrations.rb + class CreateBookmarks < ActiveRecord::Migration[5.1] def change create_table :bookmarks do |t| @@ -7,8 +10,11 @@ class CreateBookmarks < ActiveRecord::Migration[5.1] t.timestamps end - safety_assured { add_foreign_key :bookmarks, :accounts, column: :account_id, on_delete: :cascade } - safety_assured { add_foreign_key :bookmarks, :statuses, column: :status_id, on_delete: :cascade } + safety_assured do + add_foreign_key :bookmarks, :accounts, column: :account_id, on_delete: :cascade + add_foreign_key :bookmarks, :statuses, column: :status_id, on_delete: :cascade + end + add_index :bookmarks, [:account_id, :status_id], unique: true end end diff --git a/db/migrate/20180528141303_fix_accounts_unique_index.rb b/db/migrate/20180528141303_fix_accounts_unique_index.rb index bd4e158b7..bbbf28d81 100644 --- a/db/migrate/20180528141303_fix_accounts_unique_index.rb +++ b/db/migrate/20180528141303_fix_accounts_unique_index.rb @@ -12,6 +12,11 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2] end end + class StreamEntry < ApplicationRecord + # Dummy class, to make migration possible across version changes + belongs_to :account, inverse_of: :stream_entries + end + disable_ddl_transaction! def up diff --git a/db/migrate/20180831171112_create_bookmarks.rb b/db/migrate/20180831171112_create_bookmarks.rb new file mode 100644 index 000000000..5d587b7e9 --- /dev/null +++ b/db/migrate/20180831171112_create_bookmarks.rb @@ -0,0 +1,20 @@ +# This migration is a duplicate of 20180410220657 and may get ignored, see +# config/initializers/0_duplicate_migrations.rb + +class CreateBookmarks < ActiveRecord::Migration[5.1] + def change + create_table :bookmarks do |t| + t.references :account, null: false + t.references :status, null: false + + t.timestamps + end + + safety_assured do + add_foreign_key :bookmarks, :accounts, column: :account_id, on_delete: :cascade + add_foreign_key :bookmarks, :statuses, column: :status_id, on_delete: :cascade + end + + add_index :bookmarks, [:account_id, :status_id], unique: true + end +end diff --git a/db/migrate/20181024224956_migrate_account_conversations.rb b/db/migrate/20181024224956_migrate_account_conversations.rb index b718f9e1d..9f6c94fd1 100644 --- a/db/migrate/20181024224956_migrate_account_conversations.rb +++ b/db/migrate/20181024224956_migrate_account_conversations.rb @@ -1,6 +1,66 @@ class MigrateAccountConversations < ActiveRecord::Migration[5.2] disable_ddl_transaction! + class Mention < ApplicationRecord + belongs_to :account, inverse_of: :mentions + belongs_to :status, -> { unscope(where: :deleted_at) } + + delegate( + :username, + :acct, + to: :account, + prefix: true + ) + end + + class Notification < ApplicationRecord + belongs_to :account, optional: true + belongs_to :activity, polymorphic: true, optional: true + + belongs_to :status, foreign_type: 'Status', foreign_key: 'activity_id', optional: true + belongs_to :mention, foreign_type: 'Mention', foreign_key: 'activity_id', optional: true + + def target_status + mention&.status + end + end + + class AccountConversation < ApplicationRecord + belongs_to :account + belongs_to :conversation + belongs_to :last_status, -> { unscope(where: :deleted_at) }, class_name: 'Status' + + before_validation :set_last_status + + class << self + def add_status(recipient, status) + conversation = find_or_initialize_by(account: recipient, conversation_id: status.conversation_id, participant_account_ids: participants_from_status(recipient, status)) + + return conversation if conversation.status_ids.include?(status.id) + + conversation.status_ids << status.id + conversation.unread = status.account_id != recipient.id + conversation.save + conversation + rescue ActiveRecord::StaleObjectError + retry + end + + private + + def participants_from_status(recipient, status) + ((status.active_mentions.pluck(:account_id) + [status.account_id]).uniq - [recipient.id]).sort + end + end + + private + + def set_last_status + self.status_ids = status_ids.sort + self.last_status_id = status_ids.last + end + end + def up say '' say 'WARNING: This migration may take a *long* time for large instances' @@ -52,6 +112,6 @@ class MigrateAccountConversations < ActiveRecord::Migration[5.2] end def notifications_about_direct_statuses - Notification.joins(mention: :status).where(activity_type: 'Mention', statuses: { visibility: :direct }) + Notification.joins('INNER JOIN mentions ON mentions.id = notifications.activity_id INNER JOIN statuses ON statuses.id = mentions.status_id').where(activity_type: 'Mention', statuses: { visibility: :direct }) end end diff --git a/db/migrate/20190403141604_add_comment_to_invites.rb b/db/migrate/20190403141604_add_comment_to_invites.rb new file mode 100644 index 000000000..f0d7b1dcd --- /dev/null +++ b/db/migrate/20190403141604_add_comment_to_invites.rb @@ -0,0 +1,5 @@ +class AddCommentToInvites < ActiveRecord::Migration[5.2] + def change + add_column :invites, :comment, :text + end +end diff --git a/db/migrate/20190627222225_create_custom_emoji_categories.rb b/db/migrate/20190627222225_create_custom_emoji_categories.rb new file mode 100644 index 000000000..4713793e6 --- /dev/null +++ b/db/migrate/20190627222225_create_custom_emoji_categories.rb @@ -0,0 +1,9 @@ +class CreateCustomEmojiCategories < ActiveRecord::Migration[5.2] + def change + create_table :custom_emoji_categories do |t| + t.string :name, index: { unique: true } + + t.timestamps + end + end +end diff --git a/db/migrate/20190627222826_add_category_id_to_custom_emojis.rb b/db/migrate/20190627222826_add_category_id_to_custom_emojis.rb new file mode 100644 index 000000000..873b4d05f --- /dev/null +++ b/db/migrate/20190627222826_add_category_id_to_custom_emojis.rb @@ -0,0 +1,5 @@ +class AddCategoryIdToCustomEmojis < ActiveRecord::Migration[5.2] + def change + add_column :custom_emojis, :category_id, :bigint + end +end diff --git a/db/migrate/20190701022101_add_trust_level_to_accounts.rb b/db/migrate/20190701022101_add_trust_level_to_accounts.rb new file mode 100644 index 000000000..917486d2e --- /dev/null +++ b/db/migrate/20190701022101_add_trust_level_to_accounts.rb @@ -0,0 +1,5 @@ +class AddTrustLevelToAccounts < ActiveRecord::Migration[5.2] + def change + add_column :accounts, :trust_level, :integer + end +end diff --git a/db/migrate/20190705002136_create_domain_allows.rb b/db/migrate/20190705002136_create_domain_allows.rb new file mode 100644 index 000000000..83b0728d9 --- /dev/null +++ b/db/migrate/20190705002136_create_domain_allows.rb @@ -0,0 +1,9 @@ +class CreateDomainAllows < ActiveRecord::Migration[5.2] + def change + create_table :domain_allows do |t| + t.string :domain, default: '', null: false, index: { unique: true } + + t.timestamps + end + end +end diff --git a/db/migrate/20190715164535_add_instance_actor.rb b/db/migrate/20190715164535_add_instance_actor.rb new file mode 100644 index 000000000..a26d54949 --- /dev/null +++ b/db/migrate/20190715164535_add_instance_actor.rb @@ -0,0 +1,9 @@ +class AddInstanceActor < ActiveRecord::Migration[5.2] + def up + Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain) + end + + def down + Account.find_by(id: -99, actor_type: 'Application').destroy! + end +end diff --git a/db/migrate/20190726175042_add_case_insensitive_index_to_tags.rb b/db/migrate/20190726175042_add_case_insensitive_index_to_tags.rb new file mode 100644 index 000000000..057fc86ba --- /dev/null +++ b/db/migrate/20190726175042_add_case_insensitive_index_to_tags.rb @@ -0,0 +1,28 @@ +class AddCaseInsensitiveIndexToTags < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + Tag.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM tags GROUP BY lower(name) HAVING count(*) > 1').to_hash.each do |row| + canonical_tag_id = row['ids'].split(',').first + redundant_tag_ids = row['ids'].split(',')[1..-1] + + safety_assured do + execute "UPDATE accounts_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM accounts_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.account_id = t0.account_id)" + execute "UPDATE statuses_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM statuses_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.status_id = t0.status_id)" + execute "UPDATE featured_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM featured_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.account_id = t0.account_id)" + end + + Tag.where(id: redundant_tag_ids).in_batches.delete_all + end + + safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower ON tags (lower(name))' } + remove_index :tags, name: 'index_tags_on_name' + remove_index :tags, name: 'hashtag_search_index' + end + + def down + add_index :tags, :name, unique: true, algorithm: :concurrently + safety_assured { execute 'CREATE INDEX CONCURRENTLY hashtag_search_index ON tags (name text_pattern_ops)' } + remove_index :tags, name: 'index_tags_on_name_lower' + end +end diff --git a/db/migrate/20190729185330_add_score_to_tags.rb b/db/migrate/20190729185330_add_score_to_tags.rb new file mode 100644 index 000000000..75fee4b57 --- /dev/null +++ b/db/migrate/20190729185330_add_score_to_tags.rb @@ -0,0 +1,5 @@ +class AddScoreToTags < ActiveRecord::Migration[5.2] + def change + add_column :tags, :score, :int + end +end diff --git a/db/migrate/20190805123746_add_capabilities_to_tags.rb b/db/migrate/20190805123746_add_capabilities_to_tags.rb new file mode 100644 index 000000000..43c7763b1 --- /dev/null +++ b/db/migrate/20190805123746_add_capabilities_to_tags.rb @@ -0,0 +1,9 @@ +class AddCapabilitiesToTags < ActiveRecord::Migration[5.2] + def change + add_column :tags, :usable, :boolean + add_column :tags, :trendable, :boolean + add_column :tags, :listable, :boolean + add_column :tags, :reviewed_at, :datetime + add_column :tags, :requested_review_at, :datetime + end +end diff --git a/db/migrate/20190807135426_add_comments_to_domain_blocks.rb b/db/migrate/20190807135426_add_comments_to_domain_blocks.rb new file mode 100644 index 000000000..b660a71ad --- /dev/null +++ b/db/migrate/20190807135426_add_comments_to_domain_blocks.rb @@ -0,0 +1,7 @@ +class AddCommentsToDomainBlocks < ActiveRecord::Migration[5.2] + def change + add_column :domain_blocks, :private_comment, :text + add_column :domain_blocks, :public_comment, :text + end +end + diff --git a/db/migrate/20190815225426_add_last_status_at_to_tags.rb b/db/migrate/20190815225426_add_last_status_at_to_tags.rb new file mode 100644 index 000000000..d83537c47 --- /dev/null +++ b/db/migrate/20190815225426_add_last_status_at_to_tags.rb @@ -0,0 +1,6 @@ +class AddLastStatusAtToTags < ActiveRecord::Migration[5.2] + def change + add_column :tags, :last_status_at, :datetime + add_column :tags, :last_trend_at, :datetime + end +end diff --git a/db/migrate/20190819134503_add_deleted_at_to_statuses.rb b/db/migrate/20190819134503_add_deleted_at_to_statuses.rb new file mode 100644 index 000000000..5af109097 --- /dev/null +++ b/db/migrate/20190819134503_add_deleted_at_to_statuses.rb @@ -0,0 +1,5 @@ +class AddDeletedAtToStatuses < ActiveRecord::Migration[5.2] + def change + add_column :statuses, :deleted_at, :datetime + end +end diff --git a/db/migrate/20190820003045_update_statuses_index.rb b/db/migrate/20190820003045_update_statuses_index.rb new file mode 100644 index 000000000..5c2ea1f6a --- /dev/null +++ b/db/migrate/20190820003045_update_statuses_index.rb @@ -0,0 +1,13 @@ +class UpdateStatusesIndex < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + safety_assured { add_index :statuses, [:account_id, :id, :visibility, :updated_at], where: 'deleted_at IS NULL', order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20190820 } + remove_index :statuses, name: :index_statuses_20180106 + end + + def down + safety_assured { add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 } + remove_index :statuses, name: :index_statuses_20190820 + end +end diff --git a/db/migrate/20190823221802_add_local_index_to_statuses.rb b/db/migrate/20190823221802_add_local_index_to_statuses.rb new file mode 100644 index 000000000..deca25c35 --- /dev/null +++ b/db/migrate/20190823221802_add_local_index_to_statuses.rb @@ -0,0 +1,11 @@ +class AddLocalIndexToStatuses < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + add_index :statuses, [:id, :account_id], name: :index_statuses_local_20190824, algorithm: :concurrently, order: { id: :desc }, where: '(local OR (uri IS NULL)) AND deleted_at IS NULL AND visibility = 0 AND reblog_of_id IS NULL AND ((NOT reply) OR (in_reply_to_account_id = account_id))' + end + + def down + remove_index :statuses, name: :index_statuses_local_20190824 + end +end diff --git a/db/migrate/20190901035623_add_max_score_to_tags.rb b/db/migrate/20190901035623_add_max_score_to_tags.rb new file mode 100644 index 000000000..f936e9871 --- /dev/null +++ b/db/migrate/20190901035623_add_max_score_to_tags.rb @@ -0,0 +1,6 @@ +class AddMaxScoreToTags < ActiveRecord::Migration[5.2] + def change + add_column :tags, :max_score, :float + add_column :tags, :max_score_at, :datetime + end +end diff --git a/db/migrate/20190904222339_create_markers.rb b/db/migrate/20190904222339_create_markers.rb new file mode 100644 index 000000000..71ca70ac3 --- /dev/null +++ b/db/migrate/20190904222339_create_markers.rb @@ -0,0 +1,14 @@ +class CreateMarkers < ActiveRecord::Migration[5.2] + def change + create_table :markers do |t| + t.references :user, foreign_key: { on_delete: :cascade, index: false } + t.string :timeline, default: '', null: false + t.bigint :last_read_id, default: 0, null: false + t.integer :lock_version, default: 0, null: false + + t.timestamps + end + + add_index :markers, [:user_id, :timeline], unique: true + end +end diff --git a/db/migrate/20190914202517_create_account_migrations.rb b/db/migrate/20190914202517_create_account_migrations.rb new file mode 100644 index 000000000..cb9d71c09 --- /dev/null +++ b/db/migrate/20190914202517_create_account_migrations.rb @@ -0,0 +1,12 @@ +class CreateAccountMigrations < ActiveRecord::Migration[5.2] + def change + create_table :account_migrations do |t| + t.belongs_to :account, foreign_key: { on_delete: :cascade } + t.string :acct, null: false, default: '' + t.bigint :followers_count, null: false, default: 0 + t.belongs_to :target_account, foreign_key: { to_table: :accounts, on_delete: :nullify } + + t.timestamps + end + end +end diff --git a/db/migrate/20190915194355_create_account_aliases.rb b/db/migrate/20190915194355_create_account_aliases.rb new file mode 100644 index 000000000..32ce031d9 --- /dev/null +++ b/db/migrate/20190915194355_create_account_aliases.rb @@ -0,0 +1,11 @@ +class CreateAccountAliases < ActiveRecord::Migration[5.2] + def change + create_table :account_aliases do |t| + t.belongs_to :account, foreign_key: { on_delete: :cascade } + t.string :acct, null: false, default: '' + t.string :uri, null: false, default: '' + + t.timestamps + end + end +end diff --git a/db/migrate/20190917213523_add_remember_token_index.rb b/db/migrate/20190917213523_add_remember_token_index.rb new file mode 100644 index 000000000..c5b41ce64 --- /dev/null +++ b/db/migrate/20190917213523_add_remember_token_index.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddRememberTokenIndex < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def change + add_index :users, :remember_token, algorithm: :concurrently, unique: true + end +end diff --git a/db/migrate/20190927232842_add_voters_count_to_polls.rb b/db/migrate/20190927232842_add_voters_count_to_polls.rb new file mode 100644 index 000000000..846385700 --- /dev/null +++ b/db/migrate/20190927232842_add_voters_count_to_polls.rb @@ -0,0 +1,5 @@ +class AddVotersCountToPolls < ActiveRecord::Migration[5.2] + def change + add_column :polls, :voters_count, :bigint + end +end diff --git a/db/migrate/20191001213028_add_lock_version_to_account_stats.rb b/db/migrate/20191001213028_add_lock_version_to_account_stats.rb new file mode 100644 index 000000000..47f37cca2 --- /dev/null +++ b/db/migrate/20191001213028_add_lock_version_to_account_stats.rb @@ -0,0 +1,15 @@ +require Rails.root.join('lib', 'mastodon', 'migration_helpers') + +class AddLockVersionToAccountStats < ActiveRecord::Migration[5.2] + include Mastodon::MigrationHelpers + + disable_ddl_transaction! + + def up + safety_assured { add_column_with_default :account_stats, :lock_version, :integer, allow_null: false, default: 0 } + end + + def down + remove_column :account_stats, :lock_version + end +end diff --git a/db/migrate/20191007013357_update_pt_locales.rb b/db/migrate/20191007013357_update_pt_locales.rb new file mode 100644 index 000000000..b7288d38a --- /dev/null +++ b/db/migrate/20191007013357_update_pt_locales.rb @@ -0,0 +1,11 @@ +class UpdatePtLocales < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + User.where(locale: 'pt').in_batches.update_all(locale: 'pt-PT') + end + + def down + User.where(locale: 'pt-PT').in_batches.update_all(locale: 'pt') + end +end diff --git a/db/migrate/20191031163205_change_list_account_follow_nullable.rb b/db/migrate/20191031163205_change_list_account_follow_nullable.rb new file mode 100644 index 000000000..ff8911546 --- /dev/null +++ b/db/migrate/20191031163205_change_list_account_follow_nullable.rb @@ -0,0 +1,5 @@ +class ChangeListAccountFollowNullable < ActiveRecord::Migration[5.1] + def change + change_column_null :list_accounts, :follow_id, true + end +end |