Gab Social. All are welcome.
This commit is contained in:
25
db/migrate/20160220174730_create_accounts.rb
Normal file
25
db/migrate/20160220174730_create_accounts.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
class CreateAccounts < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :accounts do |t|
|
||||
t.string :username, null: false, default: ''
|
||||
t.string :domain, null: true
|
||||
|
||||
# PuSH credentials
|
||||
t.string :verify_token, null: false, default: ''
|
||||
t.string :secret, null: false, default: ''
|
||||
|
||||
# RSA key pair
|
||||
t.text :private_key, null: true
|
||||
t.text :public_key, null: false, default: ''
|
||||
|
||||
# URLs
|
||||
t.string :remote_url, null: false, default: ''
|
||||
t.string :salmon_url, null: false, default: ''
|
||||
t.string :hub_url, null: false, default: ''
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :accounts, [:username, :domain], unique: true
|
||||
end
|
||||
end
|
||||
13
db/migrate/20160220211917_create_statuses.rb
Normal file
13
db/migrate/20160220211917_create_statuses.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateStatuses < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :statuses do |t|
|
||||
t.string :uri, null: false, default: ''
|
||||
t.integer :account_id, null: false
|
||||
t.text :text, null: false, default: ''
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :statuses, :uri, unique: true
|
||||
end
|
||||
end
|
||||
12
db/migrate/20160221003140_create_users.rb
Normal file
12
db/migrate/20160221003140_create_users.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateUsers < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :users do |t|
|
||||
t.string :email, null: false, default: ''
|
||||
t.integer :account_id, null: false
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :users, :email, unique: true
|
||||
end
|
||||
end
|
||||
12
db/migrate/20160221003621_create_follows.rb
Normal file
12
db/migrate/20160221003621_create_follows.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateFollows < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :follows do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.integer :target_account_id, null: false
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :follows, [:account_id, :target_account_id], unique: true
|
||||
end
|
||||
end
|
||||
11
db/migrate/20160222122600_create_stream_entries.rb
Normal file
11
db/migrate/20160222122600_create_stream_entries.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateStreamEntries < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :stream_entries do |t|
|
||||
t.integer :account_id
|
||||
t.integer :activity_id
|
||||
t.string :activity_type
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddProfileFieldsToAccounts < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :accounts, :note, :text, null: false, default: ''
|
||||
add_column :accounts, :display_name, :string, null: false, default: ''
|
||||
add_column :accounts, :uri, :string, null: false, default: ''
|
||||
end
|
||||
end
|
||||
6
db/migrate/20160223162837_add_metadata_to_statuses.rb
Normal file
6
db/migrate/20160223162837_add_metadata_to_statuses.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AddMetadataToStatuses < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :statuses, :in_reply_to_id, :integer, null: true
|
||||
add_column :statuses, :reblog_of_id, :integer, null: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class MakeUrisNullableInStatuses < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
change_column :statuses, :uri, :string, null: true, default: nil
|
||||
end
|
||||
end
|
||||
5
db/migrate/20160223165723_add_url_to_statuses.rb
Normal file
5
db/migrate/20160223165723_add_url_to_statuses.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddUrlToStatuses < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :statuses, :url, :string, null: true, default: nil
|
||||
end
|
||||
end
|
||||
5
db/migrate/20160223165855_add_url_to_accounts.rb
Normal file
5
db/migrate/20160223165855_add_url_to_accounts.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddUrlToAccounts < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :accounts, :url, :string, null: true, default: nil
|
||||
end
|
||||
end
|
||||
12
db/migrate/20160223171800_create_favourites.rb
Normal file
12
db/migrate/20160223171800_create_favourites.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateFavourites < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :favourites do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.integer :status_id, null: false
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :favourites, [:account_id, :status_id], unique: true
|
||||
end
|
||||
end
|
||||
12
db/migrate/20160224223247_create_mentions.rb
Normal file
12
db/migrate/20160224223247_create_mentions.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateMentions < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :mentions do |t|
|
||||
t.integer :account_id
|
||||
t.integer :status_id
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :mentions, [:account_id, :status_id], unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddAttachmentAvatarToAccounts < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
change_table :accounts do |t|
|
||||
t.attachment :avatar
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_attachment :accounts, :avatar
|
||||
end
|
||||
end
|
||||
38
db/migrate/20160305115639_add_devise_to_users.rb
Normal file
38
db/migrate/20160305115639_add_devise_to_users.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
class AddDeviseToUsers < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
change_table(:users) do |t|
|
||||
## Database authenticatable
|
||||
t.string :encrypted_password, null: false, default: ""
|
||||
|
||||
## Recoverable
|
||||
t.string :reset_password_token
|
||||
t.datetime :reset_password_sent_at
|
||||
|
||||
## Rememberable
|
||||
t.datetime :remember_created_at
|
||||
|
||||
## Trackable
|
||||
t.integer :sign_in_count, default: 0, null: false
|
||||
t.datetime :current_sign_in_at
|
||||
t.datetime :last_sign_in_at
|
||||
t.inet :current_sign_in_ip
|
||||
t.inet :last_sign_in_ip
|
||||
end
|
||||
|
||||
add_index :users, :reset_password_token, unique: true
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :users, :reset_password_token
|
||||
|
||||
remove_column :users, :encrypted_password
|
||||
remove_column :users, :reset_password_token
|
||||
remove_column :users, :reset_password_sent_at
|
||||
remove_column :users, :remember_created_at
|
||||
remove_column :users, :sign_in_count
|
||||
remove_column :users, :current_sign_in_at
|
||||
remove_column :users, :current_sign_in_ip
|
||||
remove_column :users, :last_sign_in_at
|
||||
remove_column :users, :last_sign_in_ip
|
||||
end
|
||||
end
|
||||
50
db/migrate/20160306172223_create_doorkeeper_tables.rb
Normal file
50
db/migrate/20160306172223_create_doorkeeper_tables.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :oauth_applications do |t|
|
||||
t.string :name, null: false
|
||||
t.string :uid, null: false
|
||||
t.string :secret, null: false
|
||||
t.text :redirect_uri, null: false
|
||||
t.string :scopes, null: false, default: ''
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :oauth_applications, :uid, unique: true
|
||||
|
||||
create_table :oauth_access_grants do |t|
|
||||
t.integer :resource_owner_id, null: false
|
||||
t.integer :application_id, null: false
|
||||
t.string :token, null: false
|
||||
t.integer :expires_in, null: false
|
||||
t.text :redirect_uri, null: false
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :revoked_at
|
||||
t.string :scopes
|
||||
end
|
||||
|
||||
add_index :oauth_access_grants, :token, unique: true
|
||||
|
||||
create_table :oauth_access_tokens do |t|
|
||||
t.integer :resource_owner_id
|
||||
t.integer :application_id
|
||||
|
||||
# If you use a custom token generator you may need to change this column
|
||||
# from string to text, so that it accepts tokens larger than 255
|
||||
# characters. More info on custom token generators in:
|
||||
# https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
|
||||
#
|
||||
# t.text :token, null: false
|
||||
t.string :token, null: false
|
||||
|
||||
t.string :refresh_token
|
||||
t.integer :expires_in
|
||||
t.datetime :revoked_at
|
||||
t.datetime :created_at, null: false
|
||||
t.string :scopes
|
||||
end
|
||||
|
||||
add_index :oauth_access_tokens, :token, unique: true
|
||||
add_index :oauth_access_tokens, :resource_owner_id
|
||||
add_index :oauth_access_tokens, :refresh_token, unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddAttachmentHeaderToAccounts < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
change_table :accounts do |t|
|
||||
t.attachment :header
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_attachment :accounts, :header
|
||||
end
|
||||
end
|
||||
7
db/migrate/20160314164231_add_owner_to_application.rb
Normal file
7
db/migrate/20160314164231_add_owner_to_application.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class AddOwnerToApplication < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :oauth_applications, :owner_id, :integer, null: true
|
||||
add_column :oauth_applications, :owner_type, :string, null: true
|
||||
add_index :oauth_applications, [:owner_id, :owner_type]
|
||||
end
|
||||
end
|
||||
10
db/migrate/20160316103650_add_missing_indices.rb
Normal file
10
db/migrate/20160316103650_add_missing_indices.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class AddMissingIndices < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_index :users, :account_id
|
||||
add_index :statuses, :account_id
|
||||
add_index :statuses, :in_reply_to_id
|
||||
add_index :statuses, :reblog_of_id
|
||||
add_index :stream_entries, :account_id
|
||||
add_index :stream_entries, [:activity_id, :activity_type]
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddAvatarRemoteUrlToAccounts < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :accounts, :avatar_remote_url, :string, null: true, default: nil
|
||||
end
|
||||
end
|
||||
5
db/migrate/20160325130944_add_admin_to_users.rb
Normal file
5
db/migrate/20160325130944_add_admin_to_users.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddAdminToUsers < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :users, :admin, :boolean, default: false
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddSuperappToOauthApplications < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :oauth_applications, :superapp, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
||||
14
db/migrate/20160905150353_create_media_attachments.rb
Normal file
14
db/migrate/20160905150353_create_media_attachments.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class CreateMediaAttachments < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :media_attachments do |t|
|
||||
t.integer :status_id, null: true, default: nil
|
||||
t.attachment :file
|
||||
t.string :remote_url, null: false, default: ''
|
||||
t.integer :account_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :media_attachments, :status_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddSubscriptionExpiresAtToAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :accounts, :subscription_expires_at, :datetime, null: true, default: nil
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class RemoveVerifyTokenFromAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_column :accounts, :verify_token, :string, null: false, default: ''
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class RemoveOwnerFromApplication < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_index :oauth_applications, [:owner_id, :owner_type]
|
||||
remove_column :oauth_applications, :owner_id, :integer, null: true
|
||||
remove_column :oauth_applications, :owner_type, :string, null: true
|
||||
end
|
||||
end
|
||||
9
db/migrate/20161003142332_add_confirmable_to_users.rb
Normal file
9
db/migrate/20161003142332_add_confirmable_to_users.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class AddConfirmableToUsers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :users, :confirmation_token, :string
|
||||
add_column :users, :confirmed_at, :datetime
|
||||
add_column :users, :confirmation_sent_at, :datetime
|
||||
add_column :users, :unconfirmed_email, :string
|
||||
add_index :users, :confirmation_token, unique: true
|
||||
end
|
||||
end
|
||||
12
db/migrate/20161003145426_create_blocks.rb
Normal file
12
db/migrate/20161003145426_create_blocks.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateBlocks < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :blocks do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.integer :target_account_id, null: false
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :blocks, [:account_id, :target_account_id], unique: true
|
||||
end
|
||||
end
|
||||
21
db/migrate/20161006213403_rails_settings_migration.rb
Normal file
21
db/migrate/20161006213403_rails_settings_migration.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5
|
||||
ActiveRecord::Migration[5.0]
|
||||
else
|
||||
ActiveRecord::Migration[4.2]
|
||||
end
|
||||
|
||||
class RailsSettingsMigration < MIGRATION_BASE_CLASS
|
||||
def self.up
|
||||
create_table :settings do |t|
|
||||
t.string :var, :null => false
|
||||
t.text :value
|
||||
t.references :target, :null => false, :polymorphic => true
|
||||
t.timestamps :null => true
|
||||
end
|
||||
add_index :settings, [ :target_type, :target_id, :var ], :unique => true
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :settings
|
||||
end
|
||||
end
|
||||
10
db/migrate/20161009120834_create_domain_blocks.rb
Normal file
10
db/migrate/20161009120834_create_domain_blocks.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateDomainBlocks < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :domain_blocks do |t|
|
||||
t.string :domain, null: false, default: ''
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :domain_blocks, :domain, unique: true
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161027172456_add_silenced_to_accounts.rb
Normal file
5
db/migrate/20161027172456_add_silenced_to_accounts.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddSilencedToAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :accounts, :silenced, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
11
db/migrate/20161104173623_create_tags.rb
Normal file
11
db/migrate/20161104173623_create_tags.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateTags < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :tags do |t|
|
||||
t.string :name, null: false, default: ''
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :tags, :name, unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
class CreateStatusesTagsJoinTable < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_join_table :statuses, :tags do |t|
|
||||
t.index :tag_id
|
||||
t.index [:tag_id, :status_id], unique: true
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161116162355_add_locale_to_users.rb
Normal file
5
db/migrate/20161116162355_add_locale_to_users.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddLocaleToUsers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :users, :locale, :string
|
||||
end
|
||||
end
|
||||
14
db/migrate/20161119211120_create_notifications.rb
Normal file
14
db/migrate/20161119211120_create_notifications.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class CreateNotifications < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :notifications do |t|
|
||||
t.integer :account_id
|
||||
t.integer :activity_id
|
||||
t.string :activity_type
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :notifications, :account_id
|
||||
add_index :notifications, [:account_id, :activity_id, :activity_type], unique: true, name: 'account_activity'
|
||||
end
|
||||
end
|
||||
7
db/migrate/20161122163057_remove_unneeded_indexes.rb
Normal file
7
db/migrate/20161122163057_remove_unneeded_indexes.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class RemoveUnneededIndexes < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_index :notifications, name: "index_notifications_on_account_id"
|
||||
remove_index :settings, name: "index_settings_on_target_type_and_target_id"
|
||||
remove_index :statuses_tags, name: "index_statuses_tags_on_tag_id"
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161123093447_add_sensitive_to_statuses.rb
Normal file
5
db/migrate/20161123093447_add_sensitive_to_statuses.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddSensitiveToStatuses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :statuses, :sensitive, :boolean, default: false
|
||||
end
|
||||
end
|
||||
15
db/migrate/20161128103007_create_subscriptions.rb
Normal file
15
db/migrate/20161128103007_create_subscriptions.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class CreateSubscriptions < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :subscriptions do |t|
|
||||
t.string :callback_url, null: false, default: ''
|
||||
t.string :secret
|
||||
t.datetime :expires_at, null: true, default: nil
|
||||
t.boolean :confirmed, null: false, default: false
|
||||
t.integer :account_id, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :subscriptions, [:callback_url, :account_id], unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddLastSuccessfulDeliveryAtToSubscriptions < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :subscriptions, :last_successful_delivery_at, :datetime, null: true, default: nil
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161130185319_add_visibility_to_statuses.rb
Normal file
5
db/migrate/20161130185319_add_visibility_to_statuses.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddVisibilityToStatuses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :statuses, :visibility, :integer, null: false, default: 0
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
class AddInReplyToAccountIdToStatuses < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
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|
|
||||
next if status.thread.nil?
|
||||
|
||||
status.in_reply_to_account_id = status.thread.account_id
|
||||
status.save(validate: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :statuses, :in_reply_to_account_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class AddFromAccountIdToNotifications < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
add_column :notifications, :from_account_id, :integer
|
||||
|
||||
Notification.where(from_account_id: nil).where(activity_type: 'Status').update_all('from_account_id = (SELECT statuses.account_id FROM notifications AS notifications1 INNER JOIN statuses ON notifications1.activity_id = statuses.id WHERE notifications1.activity_type = \'Status\' AND notifications1.id = notifications.id)')
|
||||
Notification.where(from_account_id: nil).where(activity_type: 'Mention').update_all('from_account_id = (SELECT statuses.account_id FROM notifications AS notifications1 INNER JOIN mentions ON notifications1.activity_id = mentions.id INNER JOIN statuses ON mentions.status_id = statuses.id WHERE notifications1.activity_type = \'Mention\' AND notifications1.id = notifications.id)')
|
||||
Notification.where(from_account_id: nil).where(activity_type: 'Favourite').update_all('from_account_id = (SELECT favourites.account_id FROM notifications AS notifications1 INNER JOIN favourites ON notifications1.activity_id = favourites.id WHERE notifications1.activity_type = \'Favourite\' AND notifications1.id = notifications.id)')
|
||||
Notification.where(from_account_id: nil).where(activity_type: 'Follow').update_all('from_account_id = (SELECT follows.account_id FROM notifications AS notifications1 INNER JOIN follows ON notifications1.activity_id = follows.id WHERE notifications1.activity_type = \'Follow\' AND notifications1.id = notifications.id)')
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :notifications, :from_account_id
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161205214545_add_suspended_to_accounts.rb
Normal file
5
db/migrate/20161205214545_add_suspended_to_accounts.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddSuspendedToAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :accounts, :suspended, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddHiddenToStreamEntries < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :stream_entries, :hidden, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161222201034_add_locked_to_accounts.rb
Normal file
5
db/migrate/20161222201034_add_locked_to_accounts.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddLockedToAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :accounts, :locked, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
12
db/migrate/20161222204147_create_follow_requests.rb
Normal file
12
db/migrate/20161222204147_create_follow_requests.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateFollowRequests < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :follow_requests do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.integer :target_account_id, null: false
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :follow_requests, [:account_id, :target_account_id], unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class AddShortcodeToMediaAttachments < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
add_column :media_attachments, :shortcode, :string, null: true, default: nil
|
||||
add_index :media_attachments, :shortcode, unique: true
|
||||
|
||||
# Migrate old links
|
||||
MediaAttachment.local.update_all('shortcode = id')
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :media_attachments, :shortcode
|
||||
remove_column :media_attachments, :shortcode
|
||||
end
|
||||
end
|
||||
12
db/migrate/20170109120109_create_web_settings.rb
Normal file
12
db/migrate/20170109120109_create_web_settings.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateWebSettings < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :web_settings do |t|
|
||||
t.integer :user_id
|
||||
t.json :data
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :web_settings, :user_id, unique: true
|
||||
end
|
||||
end
|
||||
19
db/migrate/20170112154826_migrate_settings.rb
Normal file
19
db/migrate/20170112154826_migrate_settings.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class MigrateSettings < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
remove_index :settings, [:target_type, :target_id, :var]
|
||||
rename_column :settings, :target_id, :thing_id
|
||||
rename_column :settings, :target_type, :thing_type
|
||||
change_column :settings, :thing_id, :integer, null: true, default: nil
|
||||
change_column :settings, :thing_type, :string, null: true, default: nil
|
||||
add_index :settings, [:thing_type, :thing_id, :var], unique: true
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :settings, [:thing_type, :thing_id, :var]
|
||||
rename_column :settings, :thing_id, :target_id
|
||||
rename_column :settings, :thing_type, :target_type
|
||||
change_column :settings, :target_id, :integer, null: false
|
||||
change_column :settings, :target_type, :string, null: false, default: ''
|
||||
add_index :settings, [:target_type, :target_id, :var], unique: true
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170114194937_add_application_to_statuses.rb
Normal file
5
db/migrate/20170114194937_add_application_to_statuses.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddApplicationToStatuses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :statuses, :application_id, :int
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddWebsiteToOauthApplication < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :oauth_applications, :website, :string
|
||||
end
|
||||
end
|
||||
17
db/migrate/20170119214911_create_preview_cards.rb
Normal file
17
db/migrate/20170119214911_create_preview_cards.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class CreatePreviewCards < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :preview_cards do |t|
|
||||
t.integer :status_id
|
||||
t.string :url, null: false, default: ''
|
||||
|
||||
# OpenGraph
|
||||
t.string :title, null: true
|
||||
t.string :description, null: true
|
||||
t.attachment :image
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :preview_cards, :status_id, unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddSeverityToDomainBlocks < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :domain_blocks, :severity, :integer, default: 0
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddRejectMediaToDomainBlocks < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :domain_blocks, :reject_media, :boolean
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddSpoilerTextToStatuses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :statuses, :spoiler_text, :text, default: "", null: false
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddDeviseTwoFactorToUsers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :users, :encrypted_otp_secret, :string
|
||||
add_column :users, :encrypted_otp_secret_iv, :string
|
||||
add_column :users, :encrypted_otp_secret_salt, :string
|
||||
add_column :users, :consumed_timestep, :integer
|
||||
add_column :users, :otp_required_for_login, :boolean
|
||||
end
|
||||
end
|
||||
13
db/migrate/20170129000348_create_devices.rb
Normal file
13
db/migrate/20170129000348_create_devices.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateDevices < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :devices do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.string :registration_id, null: false, default: ''
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :devices, :registration_id
|
||||
add_index :devices, :account_id
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170205175257_remove_devices.rb
Normal file
5
db/migrate/20170205175257_remove_devices.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class RemoveDevices < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
drop_table :devices
|
||||
end
|
||||
end
|
||||
10
db/migrate/20170209184350_add_reply_to_statuses.rb
Normal file
10
db/migrate/20170209184350_add_reply_to_statuses.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
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)')
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :statuses, :reply
|
||||
end
|
||||
end
|
||||
13
db/migrate/20170214110202_create_reports.rb
Normal file
13
db/migrate/20170214110202_create_reports.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateReports < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :reports do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.integer :target_account_id, null: false
|
||||
t.integer :status_ids, array: true, null: false, default: []
|
||||
t.text :comment, null: false, default: ''
|
||||
t.boolean :action_taken, null: false, default: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddReblogOfIdForeignKeyToStatuses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_foreign_key :statuses, :statuses, column: :reblog_of_id, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
11
db/migrate/20170301222600_create_mutes.rb
Normal file
11
db/migrate/20170301222600_create_mutes.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateMutes < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :mutes do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.integer :target_account_id, null: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :mutes, [:account_id, :target_account_id], unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddLastEmailedAtToUsers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :users, :last_emailed_at, :datetime, null: true, default: nil
|
||||
end
|
||||
end
|
||||
12
db/migrate/20170304202101_add_type_to_media_attachments.rb
Normal file
12
db/migrate/20170304202101_add_type_to_media_attachments.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class AddTypeToMediaAttachments < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
add_column :media_attachments, :type, :integer, default: 0, null: false
|
||||
|
||||
MediaAttachment.where(file_content_type: MediaAttachment::IMAGE_MIME_TYPES).update_all(type: MediaAttachment.types[:image])
|
||||
MediaAttachment.where(file_content_type: MediaAttachment::VIDEO_MIME_TYPES).update_all(type: MediaAttachment.types[:video])
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :media_attachments, :type
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddSearchIndexToAccounts < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
execute 'CREATE INDEX search_index ON accounts USING gin((setweight(to_tsvector(\'simple\', accounts.display_name), \'A\') || setweight(to_tsvector(\'simple\', accounts.username), \'B\') || setweight(to_tsvector(\'simple\', coalesce(accounts.domain, \'\')), \'C\')));'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :accounts, name: :search_index
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddHeaderRemoteUrlToAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :accounts, :header_remote_url, :string, null: false, default: ''
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddLowercaseIndexToAccounts < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
execute 'CREATE INDEX index_accounts_on_username_and_domain_lower ON accounts (lower(username), lower(domain))'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :accounts, name: 'index_accounts_on_username_and_domain_lower'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class ChangePrimaryKeyToBigintOnStatuses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column :statuses, :id, :bigint
|
||||
change_column :statuses, :reblog_of_id, :bigint
|
||||
change_column :statuses, :in_reply_to_id, :bigint
|
||||
|
||||
change_column :media_attachments, :status_id, :bigint
|
||||
change_column :mentions, :status_id, :bigint
|
||||
change_column :notifications, :activity_id, :bigint
|
||||
change_column :preview_cards, :status_id, :bigint
|
||||
change_column :reports, :status_ids, :bigint, array: true
|
||||
change_column :statuses_tags, :status_id, :bigint
|
||||
change_column :stream_entries, :activity_id, :bigint
|
||||
end
|
||||
end
|
||||
9
db/migrate/20170322162804_add_search_index_to_tags.rb
Normal file
9
db/migrate/20170322162804_add_search_index_to_tags.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class AddSearchIndexToTags < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
execute 'CREATE INDEX hashtag_search_index ON tags USING gin(to_tsvector(\'simple\', tags.name));'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :tags, name: :hashtag_search_index
|
||||
end
|
||||
end
|
||||
13
db/migrate/20170330021336_add_counter_caches.rb
Normal file
13
db/migrate/20170330021336_add_counter_caches.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class AddCounterCaches < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :statuses, :favourites_count, :integer, null: false, default: 0
|
||||
add_column :statuses, :reblogs_count, :integer, null: false, default: 0
|
||||
add_column :accounts, :statuses_count, :integer, null: false, default: 0
|
||||
add_column :accounts, :followers_count, :integer, null: false, default: 0
|
||||
add_column :accounts, :following_count, :integer, null: false, default: 0
|
||||
end
|
||||
end
|
||||
|
||||
# To make the new fields contain correct data:
|
||||
# update statuses set favourites_count = (select count(*) from favourites where favourites.status_id = statuses.id), reblogs_count = (select count(*) from statuses as reblogs where reblogs.reblog_of_id = statuses.id);
|
||||
# update accounts set statuses_count = (select count(*) from statuses where account_id = accounts.id), followers_count = (select count(*) from follows where target_account_id = accounts.id), following_count = (select count(*) from follows where account_id = accounts.id);
|
||||
11
db/migrate/20170330163835_create_imports.rb
Normal file
11
db/migrate/20170330163835_create_imports.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateImports < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :imports do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.integer :type, null: false
|
||||
t.boolean :approved
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
11
db/migrate/20170330164118_add_attachment_data_to_imports.rb
Normal file
11
db/migrate/20170330164118_add_attachment_data_to_imports.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class AddAttachmentDataToImports < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
change_table :imports do |t|
|
||||
t.attachment :data
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_attachment :imports, :data
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddActionTakenByAccountIdToReports < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :reports, :action_taken_by_account_id, :integer
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddIndexOnMentionsStatusId < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_index :mentions, :status_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddNotificationsAndFavouritesIndices < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_index :notifications, [:activity_id, :activity_type]
|
||||
add_index :accounts, :url
|
||||
add_index :favourites, :status_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddLastWebfingeredAtToAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :accounts, :last_webfingered_at, :datetime
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddDeviseTwoFactorBackupableToUsers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :users, :otp_backup_codes, :string, array: true
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170414132105_add_language_to_statuses.rb
Normal file
5
db/migrate/20170414132105_add_language_to_statuses.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddLanguageToStatuses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :statuses, :language, :string, null: false, default: 'en'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddIndexesToReportsForAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_index :reports, :account_id
|
||||
add_index :reports, :target_account_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddAllowedLanguagesToUser < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :users, :allowed_languages, :string, array: true, default: [], null: false
|
||||
add_index :users, :allowed_languages, using: :gin
|
||||
end
|
||||
end
|
||||
12
db/migrate/20170424003227_create_account_domain_blocks.rb
Normal file
12
db/migrate/20170424003227_create_account_domain_blocks.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateAccountDomainBlocks < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :account_domain_blocks do |t|
|
||||
t.integer :account_id
|
||||
t.string :domain
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :account_domain_blocks, [:account_id, :domain], unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddStatusIdIndexToStatusesTags < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_index :statuses_tags, :status_id
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170425131920_add_media_attachment_meta.rb
Normal file
5
db/migrate/20170425131920_add_media_attachment_meta.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddMediaAttachmentMeta < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :media_attachments, :file_meta, :json
|
||||
end
|
||||
end
|
||||
12
db/migrate/20170425202925_add_oembed_to_preview_cards.rb
Normal file
12
db/migrate/20170425202925_add_oembed_to_preview_cards.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class AddOEmbedToPreviewCards < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :preview_cards, :type, :integer, default: 0, null: false
|
||||
add_column :preview_cards, :html, :text, null: false, default: ''
|
||||
add_column :preview_cards, :author_name, :string, null: false, default: ''
|
||||
add_column :preview_cards, :author_url, :string, null: false, default: ''
|
||||
add_column :preview_cards, :provider_name, :string, null: false, default: ''
|
||||
add_column :preview_cards, :provider_url, :string, null: false, default: ''
|
||||
add_column :preview_cards, :width, :integer, default: 0, null: false
|
||||
add_column :preview_cards, :height, :integer, default: 0, null: false
|
||||
end
|
||||
end
|
||||
8
db/migrate/20170427011934_re_add_owner_to_application.rb
Normal file
8
db/migrate/20170427011934_re_add_owner_to_application.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class ReAddOwnerToApplication < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :oauth_applications, :owner_id, :integer, null: true
|
||||
add_column :oauth_applications, :owner_type, :string, null: true
|
||||
add_index :oauth_applications, [:owner_id, :owner_type]
|
||||
add_foreign_key :oauth_applications, :users, column: :owner_id, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
10
db/migrate/20170506235850_create_conversations.rb
Normal file
10
db/migrate/20170506235850_create_conversations.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateConversations < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :conversations, id: :bigserial do |t|
|
||||
t.string :uri, null: true, default: nil
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :conversations, :uri, unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddConversationIdToStatuses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :statuses, :conversation_id, :bigint, null: true, default: nil
|
||||
add_index :statuses, :conversation_id
|
||||
end
|
||||
end
|
||||
11
db/migrate/20170507141759_optimize_index_subscriptions.rb
Normal file
11
db/migrate/20170507141759_optimize_index_subscriptions.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class OptimizeIndexSubscriptions < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
add_index :subscriptions, [:account_id, :callback_url], unique: true
|
||||
remove_index :subscriptions, [:callback_url, :account_id]
|
||||
end
|
||||
|
||||
def down
|
||||
add_index :subscriptions, [:callback_url, :account_id], unique: true
|
||||
remove_index :subscriptions, [:account_id, :callback_url]
|
||||
end
|
||||
end
|
||||
10
db/migrate/20170508230434_create_conversation_mutes.rb
Normal file
10
db/migrate/20170508230434_create_conversation_mutes.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateConversationMutes < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :conversation_mutes do |t|
|
||||
t.integer :account_id, null: false
|
||||
t.bigint :conversation_id, null: false
|
||||
end
|
||||
|
||||
add_index :conversation_mutes, [:account_id, :conversation_id], unique: true
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170516072309_add_index_accounts_on_uri.rb
Normal file
5
db/migrate/20170516072309_add_index_accounts_on_uri.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddIndexAccountsOnUri < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_index :accounts, :uri
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class ChangeLanguageFilterToOptOut < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_index :users, :allowed_languages
|
||||
remove_column :users, :allowed_languages
|
||||
|
||||
add_column :users, :filtered_languages, :string, array: true, default: [], null: false
|
||||
add_index :users, :filtered_languages, using: :gin
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddIndexOnMediaAttachmentsAccountId < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_index :media_attachments, :account_id
|
||||
end
|
||||
end
|
||||
41
db/migrate/20170604144747_add_foreign_keys_for_accounts.rb
Normal file
41
db/migrate/20170604144747_add_foreign_keys_for_accounts.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
class AddForeignKeysForAccounts < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_foreign_key :statuses, :accounts, on_delete: :cascade
|
||||
add_foreign_key :statuses, :accounts, column: :in_reply_to_account_id, on_delete: :nullify
|
||||
add_foreign_key :statuses, :statuses, column: :in_reply_to_id, on_delete: :nullify
|
||||
add_foreign_key :account_domain_blocks, :accounts, on_delete: :cascade
|
||||
add_foreign_key :conversation_mutes, :accounts, on_delete: :cascade
|
||||
add_foreign_key :conversation_mutes, :conversations, on_delete: :cascade
|
||||
add_foreign_key :favourites, :accounts, on_delete: :cascade
|
||||
add_foreign_key :favourites, :statuses, on_delete: :cascade
|
||||
add_foreign_key :blocks, :accounts, on_delete: :cascade
|
||||
add_foreign_key :blocks, :accounts, column: :target_account_id, on_delete: :cascade
|
||||
add_foreign_key :follow_requests, :accounts, on_delete: :cascade
|
||||
add_foreign_key :follow_requests, :accounts, column: :target_account_id, on_delete: :cascade
|
||||
add_foreign_key :follows, :accounts, on_delete: :cascade
|
||||
add_foreign_key :follows, :accounts, column: :target_account_id, on_delete: :cascade
|
||||
add_foreign_key :mutes, :accounts, on_delete: :cascade
|
||||
add_foreign_key :mutes, :accounts, column: :target_account_id, on_delete: :cascade
|
||||
add_foreign_key :imports, :accounts, on_delete: :cascade
|
||||
add_foreign_key :media_attachments, :accounts, on_delete: :nullify
|
||||
add_foreign_key :media_attachments, :statuses, on_delete: :nullify
|
||||
add_foreign_key :mentions, :accounts, on_delete: :cascade
|
||||
add_foreign_key :mentions, :statuses, on_delete: :cascade
|
||||
add_foreign_key :notifications, :accounts, on_delete: :cascade
|
||||
add_foreign_key :notifications, :accounts, column: :from_account_id, on_delete: :cascade
|
||||
add_foreign_key :preview_cards, :statuses, on_delete: :cascade
|
||||
add_foreign_key :reports, :accounts, on_delete: :cascade
|
||||
add_foreign_key :reports, :accounts, column: :target_account_id, on_delete: :cascade
|
||||
add_foreign_key :reports, :accounts, column: :action_taken_by_account_id, on_delete: :nullify
|
||||
add_foreign_key :statuses_tags, :statuses, on_delete: :cascade
|
||||
add_foreign_key :statuses_tags, :tags, on_delete: :cascade
|
||||
add_foreign_key :stream_entries, :accounts, on_delete: :cascade
|
||||
add_foreign_key :subscriptions, :accounts, on_delete: :cascade
|
||||
add_foreign_key :users, :accounts, on_delete: :cascade
|
||||
add_foreign_key :web_settings, :users, on_delete: :cascade
|
||||
add_foreign_key :oauth_access_grants, :users, column: :resource_owner_id, on_delete: :cascade
|
||||
add_foreign_key :oauth_access_grants, :oauth_applications, column: :application_id, on_delete: :cascade
|
||||
add_foreign_key :oauth_access_tokens, :users, column: :resource_owner_id, on_delete: :cascade
|
||||
add_foreign_key :oauth_access_tokens, :oauth_applications, column: :application_id, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class ChangeTagSearchIndexToBtree < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
remove_index :tags, name: :hashtag_search_index
|
||||
execute 'CREATE INDEX hashtag_search_index ON tags (name text_pattern_ops);'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :tags, name: :hashtag_search_index
|
||||
execute 'CREATE INDEX hashtag_search_index ON tags USING gin(to_tsvector(\'simple\', tags.name));'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class RemoveDefaultLanguageFromStatuses < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
change_column :statuses, :language, :string, default: nil, null: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
class AddStatusesIndexOnAccountIdId < ActiveRecord::Migration[5.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
# Statuses queried by account_id are often sorted by id. Querying statuses
|
||||
# of an account to show them in his status page is one of the most
|
||||
# significant examples.
|
||||
# Add this index to improve the performance in such cases.
|
||||
add_index 'statuses', ['account_id', 'id'], algorithm: :concurrently, name: 'index_statuses_on_account_id_id'
|
||||
|
||||
remove_index 'statuses', algorithm: :concurrently, column: 'account_id', name: 'index_statuses_on_account_id'
|
||||
end
|
||||
end
|
||||
13
db/migrate/20170623152212_create_session_activations.rb
Normal file
13
db/migrate/20170623152212_create_session_activations.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateSessionActivations < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :session_activations do |t|
|
||||
t.integer :user_id, null: false
|
||||
t.string :session_id, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :session_activations, :user_id
|
||||
add_index :session_activations, :session_id, unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddDescriptionToSessionActivations < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :session_activations, :user_agent, :string, null: false, default: ''
|
||||
add_column :session_activations, :ip, :inet
|
||||
add_foreign_key :session_activations, :users, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddAccessTokenIdToSessionActivations < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :session_activations, :access_token_id, :integer
|
||||
add_foreign_key :session_activations, :oauth_access_tokens, column: :access_token_id, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
17
db/migrate/20170711225116_fix_null_booleans.rb
Normal file
17
db/migrate/20170711225116_fix_null_booleans.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class FixNullBooleans < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
change_column_default :domain_blocks, :reject_media, false
|
||||
change_column_null :domain_blocks, :reject_media, false, false
|
||||
|
||||
change_column_default :imports, :approved, false
|
||||
change_column_null :imports, :approved, false, false
|
||||
|
||||
change_column_null :statuses, :sensitive, false, false
|
||||
change_column_null :statuses, :reply, false, false
|
||||
|
||||
change_column_null :users, :admin, false, false
|
||||
|
||||
change_column_default :users, :otp_required_for_login, false
|
||||
change_column_null :users, :otp_required_for_login, false, false
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class MakeTagSearchCaseInsensitive < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
remove_index :tags, name: :hashtag_search_index
|
||||
execute 'CREATE INDEX hashtag_search_index ON tags (lower(name) text_pattern_ops);'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :tags, name: :hashtag_search_index
|
||||
execute 'CREATE INDEX hashtag_search_index ON tags (name text_pattern_ops);'
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user