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
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20241115224430_add_flags_to_users.rb
Ruby
apache-2.0
187
the-future
437
require 'update_in_batches' class AddFlagsToUsers < ActiveRecord::Migration[6.1] using UpdateInBatches self.disable_ddl_transaction! def up add_column :users, :flags, :integer say_with_time 'Filling flags column' do User.all.update_in_batches(flags: 0) end change_column_null :users, :flag...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170215225213_add_missing_processing_columns.rb
Ruby
apache-2.0
187
the-future
317
class AddMissingProcessingColumns < ActiveRecord::Migration[4.2] def change add_column :users, :cover_image_processing, :boolean add_column :anime, :cover_image_processing, :boolean add_column :manga, :cover_image_processing, :boolean add_column :dramas, :cover_image_processing, :boolean end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210919215315_remove_paperclip_columns_from_group.rb
Ruby
apache-2.0
187
the-future
611
class RemovePaperclipColumnsFromGroup < ActiveRecord::Migration[5.2] def change remove_column :groups, :avatar_file_name remove_column :groups, :avatar_content_type remove_column :groups, :avatar_file_size remove_column :groups, :avatar_updated_at remove_column :groups, :avatar_processing remo...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161112011840_fill_library_entry_on_stories.rb
Ruby
apache-2.0
187
the-future
430
class FillLibraryEntryOnStories < ActiveRecord::Migration[4.2] def change execute <<-SQL.squish UPDATE stories s SET library_entry_id = ( SELECT le.id FROM library_entries le WHERE le.media_type = s.target_type AND le.media_id = s.target_id AND le.user_id = s.us...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161124051242_add_ips_to_users.rb
Ruby
apache-2.0
187
the-future
366
class AddIpsToUsers < ActiveRecord::Migration[4.2] def change add_column :users, :ip_addresses, :inet, array: true, default: [] execute <<~SQL.squish UPDATE users SET ip_addresses = ARRAY[current_sign_in_ip::inet, last_sign_in_ip::inet] SQL remove_column :users, :last_sign_in_ip remove...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20201030020815_add_lock_unlock_to_post.rb
Ruby
apache-2.0
187
the-future
256
class AddLockUnlockToPost < ActiveRecord::Migration[5.1] def change add_column :posts, :locked_by_id, :integer add_column :posts, :locked_at, :datetime add_column :posts, :locked_reason, :integer add_index :posts, :locked_by_id end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20200809034239_new_synopsis_description_field.rb
Ruby
apache-2.0
187
the-future
530
class NewSynopsisDescriptionField < ActiveRecord::Migration[5.1] def change Anime.logger = Logger.new(STDERR) %i(anime episodes manga chapters dramas).each do |model_name| add_column model_name, :temp_description, :jsonb, default: {}, null: false end %i( amas categories characters commun...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170115234206_add_rank_columns_to_media.rb
Ruby
apache-2.0
187
the-future
386
class AddRankColumnsToMedia < ActiveRecord::Migration[4.2] def change change_table :anime do |t| t.integer :popularity_rank t.integer :rating_rank end change_table :manga do |t| t.integer :popularity_rank t.integer :rating_rank end change_table :dramas do |t| t.intege...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20180504045902_clean_up_people.rb
Ruby
apache-2.0
187
the-future
827
class CleanUpPeople < ActiveRecord::Migration[4.2] using UpdateInBatches def change change_table :people do |t| t.jsonb :names t.string :canonical_name t.string :other_names, array: true t.text :description t.date :birthday end # Add column defaults change_column_defa...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170705052357_create_amas.rb
Ruby
apache-2.0
187
the-future
603
class CreateAmas < ActiveRecord::Migration[4.2] def change create_table :amas do |t| t.string :description, null: false, required: true t.integer :author_id, index: true, null: false t.integer :original_post_id, index: true, null: false t.integer :ama_subscribers_count, null: false, defaul...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210917003018_remove_paperclip_columns_from_person_and_character.rb
Ruby
apache-2.0
187
the-future
481
class RemovePaperclipColumnsFromPersonAndCharacter < ActiveRecord::Migration[5.2] def change remove_column :people, :image_file_name remove_column :people, :image_file_size remove_column :people, :image_content_type remove_column :people, :image_updated_at remove_column :characters, :image_file_na...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20200809221150_backfill_video_sub_dub.rb
Ruby
apache-2.0
187
the-future
290
require 'update_in_batches' class BackfillVideoSubDub < ActiveRecord::Migration[5.1] using UpdateInBatches disable_ddl_transaction! def change Video.all.update_in_batches(<<-SQL) subs = ARRAY[sub_lang]::varchar[], dubs = ARRAY[dub_lang]::varchar[] SQL end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170529105808_create_media_reaction_votes.rb
Ruby
apache-2.0
187
the-future
420
class CreateMediaReactionVotes < ActiveRecord::Migration[4.2] def change create_table :media_reaction_votes do |t| t.references :user, index: true, foreign_key: true, required: true t.references :media_reaction, index: true, foreign_key: true, required: true t...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20201206202624_change_installment_position_column.rb
Ruby
apache-2.0
187
the-future
215
class ChangeInstallmentPositionColumn < ActiveRecord::Migration[5.1] def change change_column_null :installments, :position, true change_column_default :installments, :position, from: 0, to: nil end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20211115073159_backfill_origin_for_media.rb
Ruby
apache-2.0
187
the-future
4,378
class BackfillOriginForMedia < ActiveRecord::Migration[6.0] disable_ddl_transaction! def down Anime.in_batches.update_all(origin_languages: [], origin_countries: []) Manga.in_batches.update_all(origin_languages: [], origin_countries: []) end def up updated_at = Time.now Anime.in_batches(of: 50...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170210211932_clean_up_groups.rb
Ruby
apache-2.0
187
the-future
643
class CleanUpGroups < ActiveRecord::Migration[4.2] def change # Get rid of old trending stuff execute 'DROP VIEW IF EXISTS group_members_histogram CASCADE' # Clean up Groups change_table :groups do |t| t.text :rules t.text :rules_formatted t.remove :bio, :about_formatted t.ren...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20151002044617_clean_anime.rb
Ruby
apache-2.0
187
the-future
1,412
class CleanAnime < ActiveRecord::Migration[4.2] def change # G => 1, PG => 2, R => 3, X => 4 change_column :anime, :age_rating, "integer USING ( CASE age_rating WHEN 'G' THEN 1 WHEN 'TV-Y7' THEN 1 WHEN 'PG' THEN 2 WHEN 'PG13' THEN 2 WHEN 'R17+' THEN 3 WHEN 'R18+' THEN...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20151006060753_rolify_create_roles.rb
Ruby
apache-2.0
187
the-future
455
class RolifyCreateRoles < ActiveRecord::Migration[4.2] def change create_table :roles do |t| t.string :name t.references :resource, polymorphic: true t.timestamps end create_table :users_roles, id: false do |t| t.references :user t.references :role end add_index :r...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170715212950_refill_episodes_and_chapters.rb
Ruby
apache-2.0
187
the-future
561
class RefillEpisodesAndChapters < ActiveRecord::Migration[4.2] self.disable_ddl_transaction! def change Anime.joins('LEFT OUTER JOIN episodes ON episodes.media_id = anime.id').distinct .group(:id).having('count(episodes) < anime.episode_count') .each { |a| a.episodes.create_defaults(a.episode_...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20200809034626_update_synopsis_description_field.rb
Ruby
apache-2.0
187
the-future
797
require 'update_in_batches' class UpdateSynopsisDescriptionField < ActiveRecord::Migration[5.1] using UpdateInBatches disable_ddl_transaction! def change Anime.logger = Logger.new(STDERR) %i(anime episodes manga chapters dramas).each do |model_name| model = model_name.to_s.classify.constantize ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210410224334_create_wiki_submission_logs.rb
Ruby
apache-2.0
187
the-future
334
class CreateWikiSubmissionLogs < ActiveRecord::Migration[5.2] def change create_table :wiki_submission_logs do |t| t.integer :status, null: false, default: 0 t.references :user, foreign_key: true, index: true t.references :wiki_submission, foreign_key: true, index: true t.timestamps ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170629184039_add_missing_timestamps.rb
Ruby
apache-2.0
187
the-future
581
class AddMissingTimestamps < ActiveRecord::Migration[4.2] def change tables = %i[ anime_castings anime_characters anime_productions anime_staff drama_castings drama_characters drama_staff installments manga_characters manga_staff mappings media_relationships profile_links streamers streami...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161219013436_add_onboarding_columns_to_user.rb
Ruby
apache-2.0
187
the-future
789
class AddOnboardingColumnsToUser < ActiveRecord::Migration[4.2] def change # Remove onboarding boolean remove_column :users, :onboarded # Profile Onboarding add_column :users, :profile_completed, :boolean, null: false, default: false User.where(<<-EOF.squish).update_all(profile_completed: true) ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170302181054_create_leader_chat_messages.rb
Ruby
apache-2.0
187
the-future
419
class CreateLeaderChatMessages < ActiveRecord::Migration[4.2] def change create_table :leader_chat_messages do |t| t.references :user, null: false, foreign_key: true, index: true t.references :group, null: false, foreign_key: true, index: true t.text :content, null: false t.text :content_f...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170302195631_create_group_action_logs.rb
Ruby
apache-2.0
187
the-future
410
class CreateGroupActionLogs < ActiveRecord::Migration[4.2] def change create_table :group_action_logs do |t| t.references :user, null: false, foreign_key: true t.references :group, null: false, index: true, foreign_key: true t.string :verb, null: false t.references :target, null: false, po...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20150924063228_create_doorkeeper_tables.rb
Ruby
apache-2.0
187
the-future
1,782
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, ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20180720231815_copy_data_into_new_castings.rb
Ruby
apache-2.0
187
the-future
2,722
class CopyDataIntoNewCastings < ActiveRecord::Migration[4.2] def change execute <<-SQL.squish INSERT INTO media_characters ( id, media_type, media_id, character_id, role, created_at, updated_at ) SELECT id, 'Anime' AS media_type, ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170318213404_fill_new_ratings_column.rb
Ruby
apache-2.0
187
the-future
406
require 'update_in_batches' class FillNewRatingsColumn < ActiveRecord::Migration[4.2] using UpdateInBatches disable_ddl_transaction! class LibraryEntry < ActiveRecord::Base; end def up say_with_time 'Filling new_rating column' do LibraryEntry.all.update_in_batches('new_rating = (rating * 4)') en...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170305071424_create_group_categories.rb
Ruby
apache-2.0
187
the-future
257
class CreateGroupCategories < ActiveRecord::Migration[4.2] def change create_table :group_categories do |t| t.string :name, null: false t.string :slug, null: false t.text :description t.timestamps null: false end end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170318210412_create_stats.rb
Ruby
apache-2.0
187
the-future
300
class CreateStats < ActiveRecord::Migration[4.2] def change create_table :stats do |t| t.references :user, index: true, foreign_key: true, null: false t.string :type, null: false t.jsonb :stats_data, null: false, default: {} t.timestamps null: false end end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210914024137_remove_paperclip_columns_from_media.rb
Ruby
apache-2.0
187
the-future
1,582
class RemovePaperclipColumnsFromMedia < ActiveRecord::Migration[5.2] def change remove_column :anime, :poster_image_file_name remove_column :anime, :poster_image_file_size remove_column :anime, :poster_image_content_type remove_column :anime, :poster_image_updated_at remove_column :anime, :poster_...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170426123432_add_fields_to_post_follow.rb
Ruby
apache-2.0
187
the-future
256
class AddFieldsToPostFollow < ActiveRecord::Migration[4.2] def change add_reference :post_follows, :user, index: true, foreign_key: true, required: true add_reference :post_follows, :post, index: true, foreign_key: true, required: true end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170512081514_add_join_tables_for_categories.rb
Ruby
apache-2.0
187
the-future
214
class AddJoinTablesForCategories < ActiveRecord::Migration[4.2] def change create_join_table :categories, :dramas create_join_table :anime, :categories create_join_table :categories, :manga end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20181023224914_copy_quotes_to_quote_lines.rb
Ruby
apache-2.0
187
the-future
450
class CopyQuotesToQuoteLines < ActiveRecord::Migration[4.2] def change execute <<-SQL.squish INSERT INTO quote_lines ( quote_id, character_id, "order", content, created_at, updated_at ) SELECT id, character_id, 1 AS "order",...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170417224628_add_thumbnail_to_chapter.rb
Ruby
apache-2.0
187
the-future
337
class AddThumbnailToChapter < ActiveRecord::Migration[4.2] def change add_column :chapters, :thumbnail_file_name, :string, limit: 255 add_column :chapters, :thumbnail_content_type, :string, limit: 255 add_column :chapters, :thumbnail_file_size, :integer add_column :chapters, :thumbnail_updated_at, :da...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161214200735_update_quotes.rb
Ruby
apache-2.0
187
the-future
1,388
class UpdateQuotes < ActiveRecord::Migration[4.2] def change # Add the character_id column add_column :quotes, :character_id, :integer # Delete all entries with incomplete dataset say_with_time 'Deleting quotes without Anime ID' do Quote.where(anime_id: nil).delete_all end # Move anime_...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20180719012821_create_new_cast_tables.rb
Ruby
apache-2.0
187
the-future
1,074
class CreateNewCastTables < ActiveRecord::Migration[4.2] def change create_table :media_characters do |t| t.references :media, polymorphic: true, index: true, null: false t.references :character, index: true, null: false t.integer :role, default: 0, null: false t.timestamps null: false ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161110234659_add_more_counter_caches_to_users.rb
Ruby
apache-2.0
187
the-future
232
class AddMoreCounterCachesToUsers < ActiveRecord::Migration[4.2] def change add_column :users, :posts_count, :integer, default: 0, null: false add_column :users, :ratings_count, :integer, default: 0, null: false end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170307020211_add_category_to_groups.rb
Ruby
apache-2.0
187
the-future
311
class AddCategoryToGroups < ActiveRecord::Migration[4.2] def change add_reference :groups, :category, index: true GroupCategory.create!(name: 'Misc.', id: 7) add_foreign_key :groups, :group_categories, column: 'category_id' change_column_null :groups, :category_id, false, 7 # Misc. end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170201230414_create_library_entry_logs.rb
Ruby
apache-2.0
187
the-future
727
class CreateLibraryEntryLogs < ActiveRecord::Migration[4.2] def change create_table :library_entry_logs do |t| t.references :linked_account, null: false, index: true # Copied fields from Library Entries # without null constraints t.string :media_type t.integer :media_id t.integ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210405030335_change_tag_type_in_installments.rb
Ruby
apache-2.0
187
the-future
285
class ChangeTagTypeInInstallments < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up Installment.update_all(tag: nil) change_column :installments, :tag, :integer, using: 'tag::integer' end def down change_column :installments, :tag, :string end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20200730023943_clean_up_people1.rb
Ruby
apache-2.0
187
the-future
215
class CleanUpPeople1 < ActiveRecord::Migration[5.1] def change remove_index :people, name: 'index_people_on_mal_id' remove_index :people, name: 'person_mal_id' remove_column :people, :mal_id end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20211115070151_add_original_languages_and_countries_to_media.rb
Ruby
apache-2.0
187
the-future
558
class AddOriginalLanguagesAndCountriesToMedia < ActiveRecord::Migration[6.0] def change add_column :anime, :origin_languages, :string, array: true, default: [] add_column :anime, :origin_countries, :string, array: true, default: [] add_column :manga, :origin_languages, :string, array: true, default: [] ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170515122347_add_deleted_account_user.rb
Ruby
apache-2.0
187
the-future
505
class AddDeletedAccountUser < ActiveRecord::Migration[4.2] def up add_column :users, :deleted_at, :datetime # TODO: once we get unregistered accounts, switch it to one of those User.by_name('deleted').update_all(name: "deleted_#{SecureRandom.hex(1)}") User.create!( name: 'Deleted', id: -1...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170724025320_create_community_recommendation_requests.rb
Ruby
apache-2.0
187
the-future
364
class CreateCommunityRecommendationRequests < ActiveRecord::Migration[4.2] def change create_table :community_recommendation_requests do |t| t.references :user, index: true, null: false, foreign_key: true, required: true t.string :title, required: true t.string :description, required: true ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20151003233701_clean_anime_more.rb
Ruby
apache-2.0
187
the-future
787
class CleanAnimeMore < ActiveRecord::Migration[4.2] def change # Unify column names with manga and genericize bayesian_rating name rename_column :anime, :started_airing_date, :start_date rename_column :anime, :finished_airing_date, :end_date rename_column :anime, :bayesian_rating, :average_rating ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170822072811_insert_existing_user_ip_address_and_remove_column_from_users.rb
Ruby
apache-2.0
187
the-future
434
class InsertExistingUserIpAddressAndRemoveColumnFromUsers < ActiveRecord::Migration[4.2] disable_ddl_transaction! def change User.find_each do |user| ips = user.ip_addresses.map do |ip| return puts "BAD IP: #{ip} for #{user.id}" unless ip.is_a?(IPAddr) {ip_address: ip, user_id: user.id} ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161208090624_add_settings_columns_to_user.rb
Ruby
apache-2.0
187
the-future
299
class AddSettingsColumnsToUser < ActiveRecord::Migration[4.2] def change add_column :users, :time_zone, :string add_column :users, :language, :string add_column :users, :country, :string, limit: 2 add_column :users, :share_to_global, :boolean, default: true, null: false end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170724030114_create_community_recommendation_follows.rb
Ruby
apache-2.0
187
the-future
520
class CreateCommunityRecommendationFollows < ActiveRecord::Migration[4.2] def change create_table :community_recommendation_follows do |t| t.references :user, index: true, null: false, foreign_key: true, required: true t.references :community_recommendation_request, foreign_key: true, required: true ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20151213100401_clean_up_castings.rb
Ruby
apache-2.0
187
the-future
981
class CleanUpCastings < ActiveRecord::Migration[4.2] class Casting < ActiveRecord::Base; end def change # Castable --> Media rename_column :castings, :castable_id, :media_id rename_column :castings, :castable_type, :media_type # featured -> null: false, default: false change_column_default :cas...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20180524205232_create_scrapes.rb
Ruby
apache-2.0
187
the-future
389
class CreateScrapes < ActiveRecord::Migration[4.2] def change create_table :scrapes do |t| t.text :target_url, null: false t.string :scraper_name t.integer :depth, null: false, default: 0 t.integer :max_depth, null: false, default: 0 t.references :parent t.integer :status, defa...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20180609011947_create_pro_subscriptions.rb
Ruby
apache-2.0
187
the-future
333
class CreateProSubscriptions < ActiveRecord::Migration[4.2] def change create_table :pro_subscriptions do |t| t.references :user, null: false t.integer :billing_service, null: false t.string :customer_id, null: false t.timestamps null: false end add_index :pro_subscriptions, :user_...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20220503045222_add_sfw_filter_level_to_users.rb
Ruby
apache-2.0
187
the-future
526
class AddSfwFilterLevelToUsers < ActiveRecord::Migration[6.0] disable_ddl_transaction! def up add_column :users, :sfw_filter_preference, :integer change_column_default :users, :sfw_filter_preference, 0 # 0 = SFW # 1 = NSFW (in NSFW places) # 2 = NSFW (everywhere) User.in_batches(of: 5000)....
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170723045121_backfill_nsfw_groups.rb
Ruby
apache-2.0
187
the-future
421
require 'update_in_batches' class BackfillNsfwGroups < ActiveRecord::Migration[4.2] using UpdateInBatches disable_ddl_transaction! def change say_with_time 'Settings nsfw category for nsfw Groups' do Group.where(nsfw: true).update_in_batches(category_id: 9) end say_with_time 'Filling nsfw col...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161102232654_clean_up_favorites.rb
Ruby
apache-2.0
187
the-future
290
class CleanUpFavorites < ActiveRecord::Migration[4.2] def change change_column_null :favorites, :user_id, false change_column_null :favorites, :item_id, false change_column_null :favorites, :item_type, false change_column_null :favorites, :fav_rank, false, 9999 end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170512042542_create_categories.rb
Ruby
apache-2.0
187
the-future
493
class CreateCategories < ActiveRecord::Migration[4.2] def change create_table :categories do |t| t.string :title, required: true, null: false t.string :description t.string :slug, null: false, index: true t.integer :anidb_id, index: true t.integer :parent_id, index: true t.inte...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210914002937_add_cover_image_data_to_media.rb
Ruby
apache-2.0
187
the-future
233
class AddCoverImageDataToMedia < ActiveRecord::Migration[5.2] def change add_column :anime, :cover_image_data, :jsonb add_column :manga, :cover_image_data, :jsonb add_column :dramas, :cover_image_data, :jsonb end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20151223065939_create_streaming_links.rb
Ruby
apache-2.0
187
the-future
504
class CreateStreamingLinks < ActiveRecord::Migration[4.2] def change change_table :streamers do |t| t.attachment :logo end create_table :streaming_links do |t| t.references :media, polymorphic: true, index: true, null: false t.references :streamer, index: true, foreign_key: true, null: f...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210126044815_convert_slugs_to_citext.rb
Ruby
apache-2.0
187
the-future
3,622
class ConvertSlugsToCitext < ActiveRecord::Migration[5.1] def change Anime.find_by_sql("SELECT * FROM ( SELECT id, ROW_NUMBER() OVER(PARTITION BY slug::citext ORDER BY id asc) AS row FROM anime WHERE slug IS NOT NULL ) dups WHERE dups.row > 1").each do |anime| Anime.find(anim...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170306055742_create_reblogs.rb
Ruby
apache-2.0
187
the-future
287
class CreateReblogs < ActiveRecord::Migration[4.2] def change create_table :reblogs do |t| t.references :user, index: true, foreign_key: true, null: false t.references :post, index: true, foreign_key: true, null: false t.timestamps null: false end end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161116064623_clean_up_reviews.rb
Ruby
apache-2.0
187
the-future
2,890
class CleanUpReviews < ActiveRecord::Migration[4.2] class Vote < ActiveRecord::Base; end class Review < ActiveRecord::Base has_many :votes, as: 'target', dependent: :delete_all end def change #### Media Association # anime_id -> media_id rename_column :reviews, :anime_id, :media_id # Add me...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20211002180702_fill_media_categories.rb
Ruby
apache-2.0
187
the-future
699
class FillMediaCategories < ActiveRecord::Migration[5.2] def change execute <<-SQL.squish INSERT INTO media_categories (media_type, media_id, category_id, created_at, updated_at) SELECT 'Anime' as media_type, anime_id as media_id, category_id, NOW() AS created_at, ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20151211081155_merge_manga_and_library_entries.rb
Ruby
apache-2.0
187
the-future
2,815
class MergeMangaAndLibraryEntries < ActiveRecord::Migration[4.2] def change # Anime --> Media remove_index :library_entries, [:user_id, :anime_id] rename_column :library_entries, :anime_id, :media_id add_column :library_entries, :media_type, :string change_column_null :library_entries, :media_type...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170729210024_fill_unit_count_guess_for_media.rb
Ruby
apache-2.0
187
the-future
919
class FillUnitCountGuessForMedia < ActiveRecord::Migration[4.2] disable_ddl_transaction! def change LibraryEntry.where(anime_id: Anime.where(episode_count: nil).ids) .group(:anime_id) .maximum(:progress) .each do |a, pr| begin ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170601084705_create_media_attributes.rb
Ruby
apache-2.0
187
the-future
444
class CreateMediaAttributes < ActiveRecord::Migration[4.2] def change create_table :media_attributes do |t| t.string :title, null: false, index: true, required: true t.string :high_title, null: false, required: true t.string :neutral_title, null: false, required: true t.string :low_title, ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20190211222650_switch_from_length_to_tier.rb
Ruby
apache-2.0
187
the-future
241
class SwitchFromLengthToTier < ActiveRecord::Migration[4.2] def change rename_column :pro_subscriptions, :plan, :tier add_column :users, :pro_tier, :integer User.where.not(ao_pro: nil).update_all('pro_tier = ao_pro') end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170318224640_fix_rating_frequencies.rb
Ruby
apache-2.0
187
the-future
562
class FixRatingFrequencies < ActiveRecord::Migration[4.2] def change mappings = (0.5..5).step(0.5).to_a.map do |rating| [rating, (rating * 4) - 1] end mapping_sql = mappings.map { |(old_rating, new_rating)| "'#{new_rating.to_i}', rating_frequencies->'#{old_rating}'" }.join(', ') [Anim...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20151003085835_clean_manga.rb
Ruby
apache-2.0
187
the-future
1,287
class CleanManga < ActiveRecord::Migration[4.2] def change # => Titles add_column :manga, :titles, :hstore, default: '', null: false add_column :manga, :canonical_title, :string, null: false, default: 'ja_en' add_column :manga, :abbreviated_titles, :string, array: true execute <<-SQL UPDATE ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20220613032400_create_media_castings.rb
Ruby
apache-2.0
187
the-future
274
class CreateMediaCastings < ActiveRecord::Migration[6.1] def change create_view :media_castings, materialized: true add_index :media_castings, :character_id add_index :media_castings, %i[media_type media_id] add_index :media_castings, :person_id end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20240928225045_fill_original_and_romanized_titles_on_media.rb
Ruby
apache-2.0
187
the-future
1,435
class FillOriginalAndRomanizedTitlesOnMedia < ActiveRecord::Migration[6.1] def up Anime.in_batches(of: 1000).each do |batch| batch.update_all(<<~SQL.squish) original_title = ( SELECT * FROM ( SELECT lower(concat(l, '_', c)) AS locale FROM unnest(origin_languages) l ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170502061636_expand_site_announcements.rb
Ruby
apache-2.0
187
the-future
264
class ExpandSiteAnnouncements < ActiveRecord::Migration[4.2] def change add_column :site_announcements, :title, :string, null: false add_column :site_announcements, :image_url, :string rename_column :site_announcements, :text, :description end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170919034156_add_reaction_vote_notif_settings_to_users.rb
Ruby
apache-2.0
187
the-future
438
class AddReactionVoteNotifSettingsToUsers < ActiveRecord::Migration[4.2] disable_ddl_transaction! def change User.find_each do |user| all_users_notifications = [] all_users_notifications << { setting_type: 5, user: user, fb_messenger_enabled: false, mobile_enabled: fa...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161214201646_create_quote_likes.rb
Ruby
apache-2.0
187
the-future
522
class CreateQuoteLikes < ActiveRecord::Migration[4.2] def change create_table :quote_likes do |t| t.references :user, index: true, null: false t.references :quote, index: true, null: false t.timestamps null: false end # Move existing data execute <<-SQL.squish INSERT INTO quot...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170702234704_add_tba_to_media.rb
Ruby
apache-2.0
187
the-future
265
class AddTbaToMedia < ActiveRecord::Migration[4.2] def change %i[anime dramas].each do |table| change_table table do |t| t.string :tba t.remove :started_airing_date_known end end add_column :manga, :tba, :string end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161203192738_update_anime_show_type.rb
Ruby
apache-2.0
187
the-future
275
class UpdateAnimeShowType < ActiveRecord::Migration[4.2] class Anime < ActiveRecord::Base; end def change Anime.where(show_type: nil).update_all(show_type: 1) change_column_null :anime, :show_type, false change_column_default :anime, :show_type, 1 end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210917023903_add_thumbnail_data_to_units.rb
Ruby
apache-2.0
187
the-future
233
class AddThumbnailDataToUnits < ActiveRecord::Migration[5.2] def change add_column :volumes, :thumbnail_data, :jsonb add_column :chapters, :thumbnail_data, :jsonb add_column :episodes, :thumbnail_data, :jsonb end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161221100140_add_media_associations_to_library_entry.rb
Ruby
apache-2.0
187
the-future
224
class AddMediaAssociationsToLibraryEntry < ActiveRecord::Migration[4.2] def change add_reference :library_entries, :anime add_reference :library_entries, :manga add_reference :library_entries, :drama end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210427230857_create_partial_indices_on_library_entries.rb
Ruby
apache-2.0
187
the-future
460
class CreatePartialIndicesOnLibraryEntries < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change add_index :library_entries, :manga_id, where: 'manga_id IS NOT NULL', algorithm: :concurrently, name: 'index_library_entries_on_manga_id_partial' add_index :library_entries, :anime...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170620005334_backfill_episodes_and_chapters.rb
Ruby
apache-2.0
187
the-future
481
class BackfillEpisodesAndChapters < ActiveRecord::Migration[4.2] self.disable_ddl_transaction! def change Anime.joins(:episodes) .group('anime.id') .having('count(episodes) < anime.episode_count') .each { |a| a.episodes.create_defaults(a.episode_count) } Manga.joins(:chapters) ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20160109045957_clean_up_franchises.rb
Ruby
apache-2.0
187
the-future
1,080
class CleanUpFranchises < ActiveRecord::Migration[4.2] def change ## Switch to Titleable concern add_column :franchises, :titles, :hstore, default: '', null: false add_column :franchises, :canonical_title, :string, null: false, default: 'en_jp' execute <<-SQL UPDATE franchises SET titles =...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20171013043506_index_aozora_ids.rb
Ruby
apache-2.0
187
the-future
313
class IndexAozoraIds < ActiveRecord::Migration[4.2] disable_ddl_transaction! def change add_index :users, :ao_id, algorithm: :concurrently, unique: true add_index :posts, :ao_id, algorithm: :concurrently, unique: true add_index :comments, :ao_id, algorithm: :concurrently, unique: true end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20250518061929_fill_bumped_at_on_posts.rb
Ruby
apache-2.0
187
the-future
556
class FillBumpedAtOnPosts < ActiveRecord::Migration[6.1] using UpdateInBatches disable_ddl_transaction! def up Post.unscoped.all.update_in_batches(<<~SQL.squish) bumped_at = coalesce( ( SELECT created_at FROM comments WHERE comments.post_id = posts.id A...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20211002175842_add_media_categories.rb
Ruby
apache-2.0
187
the-future
286
class AddMediaCategories < ActiveRecord::Migration[5.2] def change create_table :media_categories do |t| t.references :media, null: false, index: true, polymorphic: true t.references :category, null: false, index: true t.timestamps null: false end end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161114042030_fix_migrating_comments.rb
Ruby
apache-2.0
187
the-future
1,073
class FixMigratingComments < ActiveRecord::Migration[4.2] class Substory < ActiveRecord::Base belongs_to :user belongs_to :target, polymorphic: true enum substory_type: { followed: 0, status_update: 1, comment: 2, progress: 3, reply: 4 } end def change # Referent...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170116051758_create_media_relationships.rb
Ruby
apache-2.0
187
the-future
309
class CreateMediaRelationships < ActiveRecord::Migration[4.2] def change create_table :media_relationships do |t| t.references :source, polymorphic: true, null: false, index: true t.references :destination, polymorphic: true, null: false t.integer :role, null: false end end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170318220421_switch_to_new_ratings.rb
Ruby
apache-2.0
187
the-future
323
class SwitchToNewRatings < ActiveRecord::Migration[4.2] def change missed_entries = LibraryEntry.where(new_rating: nil).where.not(rating: nil) missed_entries.update_all('new_rating = (rating * 4) - 1') remove_column :library_entries, :rating rename_column :library_entries, :new_rating, :rating end e...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20200812034201_update_user_title_language_preference_enum.rb
Ruby
apache-2.0
187
the-future
432
class UpdateUserTitleLanguagePreferenceEnum < ActiveRecord::Migration[5.1] def change change_column_default :users, :title_language_preference, from: 'canonical', to: nil change_column :users, :title_language_preference, "integer USING ( CASE lower(title_language_preference) WHEN 'canonical' THEN ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170615000439_add_media_reaction_id_to_library_entry.rb
Ruby
apache-2.0
187
the-future
303
class AddMediaReactionIdToLibraryEntry < ActiveRecord::Migration[4.2] def change # Disable timeout ActiveRecord::Base.connection.execute('SET statement_timeout = 0') add_column :library_entries, :media_reaction_id, :integer add_foreign_key :library_entries, :media_reactions end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20171231032518_fill_length_on_episodes.rb
Ruby
apache-2.0
187
the-future
225
class FillLengthOnEpisodes < ActiveRecord::Migration[4.2] def change Episode.where(length: nil).update_all(<<-SQL.squish) length = (SELECT episode_length FROM anime where id = episodes.media_id) SQL end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20150926085842_delete_legacy_tables.rb
Ruby
apache-2.0
187
the-future
576
class DeleteLegacyTables < ActiveRecord::Migration[4.2] def change # Replace with OAuth shit or rebuild separate from OAuth # Currently is mixing concerns drop_table :apps # Move to archive server, no longer used drop_table :forem_categories drop_table :forem_forums drop_table :forem_grou...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20200802164318_add_regions_to_streaming_links.rb
Ruby
apache-2.0
187
the-future
223
class AddRegionsToStreamingLinks < ActiveRecord::Migration[5.1] def change add_column :streaming_links, :regions, :string, array: true, default: ["US"] add_index :streaming_links, :regions, using: 'GIN' end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210917063653_remove_paperclip_columns_from_units.rb
Ruby
apache-2.0
187
the-future
790
class RemovePaperclipColumnsFromUnits < ActiveRecord::Migration[5.2] def change remove_column :episodes, :thumbnail_file_name remove_column :episodes, :thumbnail_file_size remove_column :episodes, :thumbnail_content_type remove_column :episodes, :thumbnail_updated_at remove_column :episodes, :thum...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20180314015934_add_release_schedule_to_media.rb
Ruby
apache-2.0
187
the-future
231
class AddReleaseScheduleToMedia < ActiveRecord::Migration[4.2] def change add_column :anime, :release_schedule, :text add_column :manga, :release_schedule, :text add_column :dramas, :release_schedule, :text end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20151007055934_remove_default_average_rating_and_move_manga_average_rating_to_correct_column.rb
Ruby
apache-2.0
187
the-future
604
class RemoveDefaultAverageRatingAndMoveMangaAverageRatingToCorrectColumn < ActiveRecord::Migration[4.2] def change change_column_null :anime, :average_rating, true reversible do |dir| dir.up do change_column_default :anime, :average_rating, nil execute 'UPDATE anime SET average_rating=NU...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20210605031927_add_system_user.rb
Ruby
apache-2.0
187
the-future
308
class AddSystemUser < ActiveRecord::Migration[5.2] def change # TODO: once we get unregistered accounts, switch it to one of those User.new( name: 'System', id: -11, email: 'noreply+system@kitsu.app', password: SecureRandom.base64(45) ).save!(validate: false) end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170211082904_add_new_settings_to_groups.rb
Ruby
apache-2.0
187
the-future
256
class AddNewSettingsToGroups < ActiveRecord::Migration[4.2] def change change_table :groups do |t| t.integer :privacy, null: false, default: 0 t.string :locale t.string :tags, array: true, default: [], null: false end end end
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20151213085908_polymorphize_episodes.rb
Ruby
apache-2.0
187
the-future
379
class PolymorphizeEpisodes < ActiveRecord::Migration[4.2] def change rename_column :episodes, :anime_id, :media_id change_column_null :episodes, :media_id, false add_column :episodes, :media_type, :string change_column_null :episodes, :media_type, false, 'Anime' add_index :episodes, [:media_type, ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20180329215148_add_seconds_to_lengths.rb
Ruby
apache-2.0
187
the-future
468
require 'update_in_batches' class AddSecondsToLengths < ActiveRecord::Migration[4.2] using UpdateInBatches def change Anime.all.update_in_batches(<<-SQL.squish) episode_length = episode_length * 60, total_length = total_length * 60 SQL Drama.all.update_in_batches(<<-SQL.squish) episo...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20161129050639_create_reports.rb
Ruby
apache-2.0
187
the-future
671
class CreateReports < ActiveRecord::Migration[4.2] def change create_table :reports do |t| # To be filled out by reporter only t.references :naughty, null: false, polymorphic: true, index: true t.integer :reason, null: false t.text :explanation # To be filled out automatically ...
github
hummingbird-me/kitsu-server
https://github.com/hummingbird-me/kitsu-server
db/migrate/20170719070649_create_uploads.rb
Ruby
apache-2.0
187
the-future
318
class CreateUploads < ActiveRecord::Migration[4.2] def change create_table :uploads do |t| t.references :owner, polymorphic: true, index: true t.references :user, foreign_key: true, index: true, null: false t.attachment :content, required: true t.timestamps null: false end end end