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/20161003225612_move_old_stories.rb | Ruby | apache-2.0 | 187 | the-future | 3,324 | class MoveOldStories < ActiveRecord::Migration[4.2]
class Story < ActiveRecord::Base
belongs_to :library_entry
belongs_to :user
belongs_to :target, polymorphic: true
belongs_to :group
has_many :substories
has_many :notifications, as: :source
end
class Substory < ActiveRecord::Base
belo... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170802083750_convert_episode_number_to_absolute_system.rb | Ruby | apache-2.0 | 187 | the-future | 845 | require 'update_in_batches'
class ConvertEpisodeNumberToAbsoluteSystem < ActiveRecord::Migration[4.2]
using UpdateInBatches
disable_ddl_transaction!
def change
execute <<-SQL.squish
CREATE TEMPORARY TABLE absolute_numbers (id, abs) AS
SELECT id, (row_number() OVER (
PARTITION BY medi... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170224050925_convert_rank_to_permissions.rb | Ruby | apache-2.0 | 187 | the-future | 738 | class ConvertRankToPermissions < ActiveRecord::Migration[4.2]
class GroupMember < ActiveRecord::Base
has_many :permissions, class_name: 'GroupPermission'
enum rank: %i[pleb mod admin]
end
class GroupPermission < ActiveRecord::Base
belongs_to :group_member, required: true
enum permission: %i[owner ... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20241027085701_add_index_to_unit_status.rb | Ruby | apache-2.0 | 187 | the-future | 227 | class AddIndexToUnitStatus < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def change
add_index :chapters, :status, algorithm: :concurrently
add_index :episodes, :status, algorithm: :concurrently
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20210921231835_remove_paperclip_columns_from_uploads.rb | Ruby | apache-2.0 | 187 | the-future | 328 | class RemovePaperclipColumnsFromUploads < ActiveRecord::Migration[5.2]
def change
remove_column :uploads, :content_content_type
remove_column :uploads, :content_file_name
remove_column :uploads, :content_file_size
remove_column :uploads, :content_updated_at
remove_column :uploads, :content_meta
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20180810153156_clean_up_quotes.rb | Ruby | apache-2.0 | 187 | the-future | 611 | class CleanUpQuotes < ActiveRecord::Migration[4.2]
def change
say_with_time 'Filling character_id' do
Quote.includes(:media).find_each do |quote|
title = quote.media&.canonical_title&.gsub("'", '')
next if title.nil?
char = AlgoliaCharactersIndex.index.search(quote.character_name,
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161026215344_add_comment_threading.rb | Ruby | apache-2.0 | 187 | the-future | 202 | class AddCommentThreading < ActiveRecord::Migration[4.2]
def change
add_column :comments, :parent_id, :integer, index: true
add_foreign_key :comments, :comments, column: 'parent_id'
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20180206225558_localize_character_names.rb | Ruby | apache-2.0 | 187 | the-future | 937 | require 'update_in_batches'
class LocalizeCharacterNames < ActiveRecord::Migration[4.2]
using UpdateInBatches
def change
Anime.logger = Logger.new(STDERR)
# Add names hash, canonical_name string, other_names array
change_table :characters do |t|
t.jsonb :names
t.string :canonical_name
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20160629073541_create_list_imports.rb | Ruby | apache-2.0 | 187 | the-future | 655 | class CreateListImports < ActiveRecord::Migration[4.2]
def change
create_table :list_imports do |t|
# STI type such as ListImport::MyAnimeList
t.string :type, null: false
# Owner
t.references :user, null: false
# Strategy (:greater, :obliterate)
t.integer :strategy, null: false... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161110055102_change_public_column_to_private_linked_profiles.rb | Ruby | apache-2.0 | 187 | the-future | 215 | class ChangePublicColumnToPrivateLinkedProfiles < ActiveRecord::Migration[4.2]
def change
rename_column :linked_profiles, :public, :private
change_column_default :linked_profiles, :private, true
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170721022437_add_default_to_hidden_on_group_members_and_follows.rb | Ruby | apache-2.0 | 187 | the-future | 311 | class AddDefaultToHiddenOnGroupMembersAndFollows < ActiveRecord::Migration[4.2]
def change
change_column_default :group_members, :hidden, true
change_column_null :group_members, :hidden, false
change_column_default :follows, :hidden, true
change_column_null :follows, :hidden, false
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20200803004935_add_streamable_to_videos.rb | Ruby | apache-2.0 | 187 | the-future | 276 | class AddStreamableToVideos < ActiveRecord::Migration[5.1]
def change
rename_column :videos, :available_regions, :regions
add_column :videos, :subs, :string, array: true, default: ["en"]
add_column :videos, :dubs, :string, array: true, default: ["ja"]
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170728231327_add_defaults_for_reaction_skipped.rb | Ruby | apache-2.0 | 187 | the-future | 221 | class AddDefaultsForReactionSkipped < ActiveRecord::Migration[4.2]
def change
change_column_null :library_entries, :reaction_skipped, false
change_column_default :library_entries, :reaction_skipped, 0
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170909082819_add_streaming_links_count_to_streamers.rb | Ruby | apache-2.0 | 187 | the-future | 210 | require 'counter_cache_resets'
class AddStreamingLinksCountToStreamers < ActiveRecord::Migration[4.2]
def change
add_column :streamers, :streaming_links_count, :integer, null: false, default: 0
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170829213002_create_hashtags.rb | Ruby | apache-2.0 | 187 | the-future | 273 | class CreateHashtags < ActiveRecord::Migration[4.2]
def change
create_table :hashtags do |t|
t.string :name, null: false
t.integer :kind, null: false, default: 0
t.references :item, polymorphic: true
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170107034610_unify_media_type_columns.rb | Ruby | apache-2.0 | 187 | the-future | 225 | class UnifyMediaTypeColumns < ActiveRecord::Migration[4.2]
def change
rename_column :manga, :manga_type, :subtype
rename_column :anime, :show_type, :subtype
rename_column :dramas, :show_type, :subtype
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20201126190937_change_favorite_fav_rank_column.rb | Ruby | apache-2.0 | 187 | the-future | 208 | class ChangeFavoriteFavRankColumn < ActiveRecord::Migration[5.1]
def change
change_column_null :favorites, :fav_rank, true
change_column_default :favorites, :fav_rank, from: 9999, to: nil
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170224041615_create_group_reports.rb | Ruby | apache-2.0 | 187 | the-future | 577 | class CreateGroupReports < ActiveRecord::Migration[4.2]
def change
create_table :group_reports do |t|
t.text :explanation
t.integer :reason, null: false
t.integer :status, null: false, index: true, default: 0
t.references :group, index: true, foreign_key: true, null: false
t.referenc... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170705053245_create_ama_subscribers.rb | Ruby | apache-2.0 | 187 | the-future | 347 | class CreateAMASubscribers < ActiveRecord::Migration[4.2]
def change
create_table :ama_subscribers do |t|
t.references :ama, foreign_key: true, index: true, null: false
t.references :user, foreign_key: true, index: true, null: false
t.index %i[ama_id user_id], unique: true
t.timestamps nul... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20210605015255_create_wordfilters.rb | Ruby | apache-2.0 | 187 | the-future | 350 | class CreateWordfilters < ActiveRecord::Migration[5.2]
def change
create_table :wordfilters do |t|
t.text :pattern, null: false
t.boolean :regex_enabled, null: false, default: false
t.integer :locations, null: false, default: 0
t.integer :action, null: false, default: 0
t.timestamps ... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170204005149_move_user_website_to_profile_link_site.rb | Ruby | apache-2.0 | 187 | the-future | 327 | class MoveUserWebsiteToProfileLinkSite < ActiveRecord::Migration[4.2]
def change
User.where.not(website: nil).find_each do |user|
ProfileLink.create(
url: user.website.split(' ').first,
profile_link_site_id: 29,
user_id: user.id
)
end
remove_column :users, :website
e... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20210613042826_add_hidden_at_to_user_content.rb | Ruby | apache-2.0 | 187 | the-future | 233 | class AddHiddenAtToUserContent < ActiveRecord::Migration[5.2]
def change
add_column :media_reactions, :hidden_at, :datetime
add_column :posts, :hidden_at, :datetime
add_column :comments, :hidden_at, :datetime
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20180110055601_fill_time_spent_on_library_entries.rb | Ruby | apache-2.0 | 187 | the-future | 1,055 | require 'update_in_batches'
class FillTimeSpentOnLibraryEntries < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
using UpdateInBatches
def change
execute <<-SQL.squish
CREATE TEMPORARY TABLE library_spents AS (
SELECT le.id, (
SELECT sum(length)
FROM episodes e
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170311003803_update_library_entry_logs.rb | Ruby | apache-2.0 | 187 | the-future | 207 | class UpdateLibraryEntryLogs < ActiveRecord::Migration[4.2]
def change
change_column_null :library_entry_logs, :media_id, false
change_column_null :library_entry_logs, :media_type, false
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170614063228_create_one_signal_players.rb | Ruby | apache-2.0 | 187 | the-future | 276 | class CreateOneSignalPlayers < ActiveRecord::Migration[4.2]
def change
create_table :one_signal_players do |t|
t.references :user, index: true, foreign_key: true
t.string :player_id
t.integer :platform
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20200418043417_add_permissions_to_users.rb | Ruby | apache-2.0 | 187 | the-future | 491 | require 'update_in_batches'
class AddPermissionsToUsers < ActiveRecord::Migration[5.1]
using UpdateInBatches
self.disable_ddl_transaction!
def up
add_column :users, :permissions, :integer, default: 0
say_with_time 'Filling permissions column' do
User.all.update_in_batches(permissions: 0)
end
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20180921200713_create_global_stats.rb | Ruby | apache-2.0 | 187 | the-future | 241 | class CreateGlobalStats < ActiveRecord::Migration[4.2]
def change
create_table :global_stats do |t|
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/20170728231231_fill_reaction_skipped.rb | Ruby | apache-2.0 | 187 | the-future | 221 | require 'update_in_batches'
class FillReactionSkipped < ActiveRecord::Migration[4.2]
using UpdateInBatches
disable_ddl_transaction!
def change
LibraryEntry.all.update_in_batches(reaction_skipped: 0)
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20211001221303_add_ancestry_to_categories.rb | Ruby | apache-2.0 | 187 | the-future | 216 | class AddAncestryToCategories < ActiveRecord::Migration[5.2]
def change
add_column :categories, :ancestry, :string, collation: 'POSIX'
add_index :categories, :ancestry, opclass: :text_pattern_ops
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161214055929_remove_zero_counts_from_media.rb | Ruby | apache-2.0 | 187 | the-future | 216 | class RemoveZeroCountsFromMedia < ActiveRecord::Migration[4.2]
def change
Anime.where(episode_count: 0).update_all(episode_count: nil)
Manga.where(chapter_count: 0).update_all(chapter_count: nil)
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170108051834_fill_media_associations_on_library_entry.rb | Ruby | apache-2.0 | 187 | the-future | 568 | require 'update_in_batches'
class FillMediaAssociationsOnLibraryEntry < ActiveRecord::Migration[4.2]
using UpdateInBatches
self.disable_ddl_transaction!
def up
say_with_time 'Filling anime_id column' do
LibraryEntry.where(media_type: 'Anime')
.update_in_batches('anime_id = media_id')
end
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20221204041942_add_indices_to_problems.rb | Ruby | apache-2.0 | 187 | the-future | 1,734 | class AddIndicesToProblems < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def change
# Index on age ratings
add_index :anime, :age_rating,
comment: 'Provide index-only counts by age rating filter',
algorithm: :concurrently,
if_not_exists: true
add_index :manga, :age_rating,
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170319071813_remove_required_columns_on_users.rb | Ruby | apache-2.0 | 187 | the-future | 230 | class RemoveRequiredColumnsOnUsers < ActiveRecord::Migration[4.2]
def change
change_column_null :users, :email, true
change_column_null :users, :name, true
change_column_null :users, :password_digest, true
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170214075641_create_group_invites.rb | Ruby | apache-2.0 | 187 | the-future | 399 | class CreateGroupInvites < ActiveRecord::Migration[4.2]
def change
create_table :group_invites do |t|
t.references :group, index: true, foreign_key: true, null: false
t.references :user, index: true, foreign_key: true, null: false
t.references :sender, index: true, null: false
t.foreign_ke... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20181025194801_add_confidential_to_doorkeeper_application.rb | Ruby | apache-2.0 | 187 | the-future | 279 | class AddConfidentialToDoorkeeperApplication < ActiveRecord::Migration[4.2]
def change
add_column(
:oauth_applications,
:confidential,
:boolean,
null: false,
default: true # maintaining backwards compatibility: require secrets
)
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170723224959_backfill_nsfw_entries.rb | Ruby | apache-2.0 | 187 | the-future | 512 | require 'update_in_batches'
class BackfillNsfwEntries < ActiveRecord::Migration[4.2]
using UpdateInBatches
disable_ddl_transaction!
def change
say_with_time 'Filling nsfw column for Library Entries' do
LibraryEntry.joins(:anime).where('anime.age_rating = 3').update_in_batches(nsfw: true)
Library... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20241108023205_create_ip_cities.rb | Ruby | apache-2.0 | 187 | the-future | 275 | class CreateIPCities < ActiveRecord::Migration[6.1]
def change
create_table :ip_cities, id: false do |t|
t.inet :start_ip, null: false
t.inet :end_ip, null: false
t.integer :geoname_id, null: false
t.index [:start_ip, :end_ip]
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170104002112_rename_linked_profiles_and_linked_sites.rb | Ruby | apache-2.0 | 187 | the-future | 1,404 | class RenameLinkedProfilesAndLinkedSites < ActiveRecord::Migration[4.2]
def change
# rename LinkedProfile -> LinkedAccount
rename_table :linked_profiles, :linked_accounts
# remove LinkedSite association + will remove index
remove_column :linked_accounts, :linked_site_id, :integer
# remove url
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161110060801_add_counter_caches_to_user.rb | Ruby | apache-2.0 | 187 | the-future | 389 | class AddCounterCachesToUser < ActiveRecord::Migration[4.2]
def change
add_column :users, :comments_count, :integer, default: 0, null: false
add_column :users, :likes_given_count, :integer, default: 0, null: false
add_column :users, :likes_received_count, :integer, default: 0, null: false
add_column :... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170819034850_fill_slug_on_users.rb | Ruby | apache-2.0 | 187 | the-future | 250 | require 'update_in_batches'
class FillSlugOnUsers < ActiveRecord::Migration[4.2]
using UpdateInBatches
disable_ddl_transaction!
def change
say_with_time 'Filling slugs' do
User.all.update_in_batches('slug = name')
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170308043418_add_member_and_ban_notes.rb | Ruby | apache-2.0 | 187 | the-future | 525 | class AddMemberAndBanNotes < ActiveRecord::Migration[4.2]
def change
# Add GroupBan#notes column
add_column :group_bans, :notes, :text
add_column :group_bans, :notes_formatted, :text
# Add GroupMemberNote table
create_table :group_member_notes do |t|
t.references :group_member, null: false,... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170302012154_create_group_tickets.rb | Ruby | apache-2.0 | 187 | the-future | 812 | class CreateGroupTickets < ActiveRecord::Migration[4.2]
def change
create_table :group_tickets do |t|
t.references :user, foreign_key: true, index: true, null: false
t.references :group, foreign_key: true, index: true, null: false
t.references :assignee, index: true
t.foreign_key :users, c... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20210427225015_remove_unused_indices.rb | Ruby | apache-2.0 | 187 | the-future | 1,037 | class RemoveUnusedIndices < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def change
# We no longer use substories
remove_index :substories, :created_at
remove_index :substories, :deleted_at
remove_index :substories, :story_id
remove_index :substories, :target_id
remove_index :substo... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161130210427_add_indices_to_all_the_things.rb | Ruby | apache-2.0 | 187 | the-future | 523 | class AddIndicesToAllTheThings < ActiveRecord::Migration[4.2]
def change
add_index :favorites, [:user_id, :item_type]
add_index :comments, :parent_id
add_index :comments, :post_id
add_index :comments, :deleted_at
add_index :posts, :deleted_at
add_index :library_entries, [:user_id, :media_type]... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161129192003_fix_empty_show_type.rb | Ruby | apache-2.0 | 187 | the-future | 206 | class FixEmptyShowType < ActiveRecord::Migration[4.2]
def change
say_with_time 'Adding show_type to anime missing it' do
Anime.where(show_type: nil).update_all(show_type: :TV)
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20240928224825_add_original_and_romanized_title_columns_to_media.rb | Ruby | apache-2.0 | 187 | the-future | 396 | class AddOriginalAndRomanizedTitleColumnsToMedia < ActiveRecord::Migration[6.1]
def change
add_column :anime, :original_title, :string
add_column :manga, :original_title, :string
add_column :dramas, :original_title, :string
add_column :anime, :romanized_title, :string
add_column :manga, :romanized... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161019004726_create_linked_profiles.rb | Ruby | apache-2.0 | 187 | the-future | 563 | class CreateLinkedProfiles < ActiveRecord::Migration[4.2]
def change
create_table :linked_profiles do |t|
t.references :user, index: true, foreign_key: true, null: false
t.references :linked_site, index: true, foreign_key: true, null: false
t.string :external_user_id, null: false
t.string... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170430050223_backfill_library_timestamps.rb | Ruby | apache-2.0 | 187 | the-future | 375 | require 'update_in_batches'
class BackfillLibraryTimestamps < ActiveRecord::Migration[4.2]
using UpdateInBatches
self.disable_ddl_transaction!
def change
LibraryEntry.where("progress > 0").update_in_batches(<<-SQL)
progressed_at = updated_at,
finished_at = CASE WHEN status = #{LibraryEntry.statu... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20241103040257_add_moderation_scores_to_users_and_content.rb | Ruby | apache-2.0 | 187 | the-future | 310 | class AddModerationScoresToUsersAndContent < ActiveRecord::Migration[6.1]
def change
add_column :users, :moderation_scores, :jsonb
add_column :posts, :moderation_scores, :jsonb
add_column :comments, :moderation_scores, :jsonb
add_column :media_reactions, :moderation_scores, :jsonb
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20180823024854_create_pro_gifts.rb | Ruby | apache-2.0 | 187 | the-future | 246 | class CreateProGifts < ActiveRecord::Migration[4.2]
def change
create_table :pro_gifts do |t|
t.references :from, null: false
t.references :to, null: false
t.text :message
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170226192407_add_counter_caches_to_groups.rb | Ruby | apache-2.0 | 187 | the-future | 239 | class AddCounterCachesToGroups < ActiveRecord::Migration[4.2]
def change
change_table :groups do |t|
t.integer :leaders_count, default: 0, null: false
t.integer :neighbors_count, default: 0, null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20151001030141_clean_up_library_entries.rb | Ruby | apache-2.0 | 187 | the-future | 463 | class CleanUpLibraryEntries < ActiveRecord::Migration[4.2]
def change
remove_column :library_entries, :last_watched
remove_column :library_entries, :imported
# Convert status to enum
change_column :library_entries, :status, "integer USING (
CASE status
WHEN 'Currently Watching' THEN 1
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20151130032929_create_pro_membership_plans.rb | Ruby | apache-2.0 | 187 | the-future | 336 | class CreateProMembershipPlans < ActiveRecord::Migration[4.2]
def change
create_table :pro_membership_plans do |t|
t.string :name, null: false
t.integer :amount, null: false
t.integer :duration, null: false
t.boolean :recurring, null: false, default: false
t.timestamps null: false
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170319040245_fill_status_on_users.rb | Ruby | apache-2.0 | 187 | the-future | 356 | require 'update_in_batches'
class FillStatusOnUsers < ActiveRecord::Migration[4.2]
using UpdateInBatches
self.disable_ddl_transaction!
def change
say_with_time 'Filling status column' do
User.all.update_in_batches(status: 1)
end
change_column_null :users, :status, false, 1
change_column_d... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170116102736_rename_anime_producers_to_productions.rb | Ruby | apache-2.0 | 187 | the-future | 211 | class RenameAnimeProducersToProductions < ActiveRecord::Migration[4.2]
def change
rename_table :anime_producers, :anime_productions
add_column :anime_productions, :role, :integer, default: 0
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170512042843_create_category_favorites.rb | Ruby | apache-2.0 | 187 | the-future | 297 | class CreateCategoryFavorites < ActiveRecord::Migration[4.2]
def change
create_table :category_favorites do |t|
t.references :user, foreign_key: true, index: true, null: false
t.references :category, foreign_key: true, index: true
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20210406023328_create_wiki_submissions.rb | Ruby | apache-2.0 | 187 | the-future | 519 | class CreateWikiSubmissions < ActiveRecord::Migration[5.2]
def change
create_table :wiki_submissions do |t|
t.string :title
t.text :notes
t.integer :status, null: false, default: 0
t.jsonb :data, null: false, default: {}
t.references :user, index: true, foreign_key: true
t.int... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20181215004955_add_recalculated_at_to_stats.rb | Ruby | apache-2.0 | 187 | the-future | 243 | class AddRecalculatedAtToStats < ActiveRecord::Migration[4.2]
def change
add_column :stats, :recalculated_at, :datetime
Stat.update_all('recalculated_at = created_at')
change_column_null :stats, :recalculated_at, false
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20160527090120_rename_title_key.rb | Ruby | apache-2.0 | 187 | the-future | 1,766 | class RenameTitleKey < ActiveRecord::Migration[4.2]
class Anime < ActiveRecord::Base; end
class Drama < ActiveRecord::Base; end
class Manga < ActiveRecord::Base; end
class Episode < ActiveRecord::Base; end
def change
# Copy values from :ja_en to new key :en_jp
execute <<-SQL
UPDATE anime
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20241109052107_create_ip_filters.rb | Ruby | apache-2.0 | 187 | the-future | 259 | class CreateIPFilters < ActiveRecord::Migration[6.1]
def change
create_table :ip_filters do |t|
t.integer :type, null: false
t.text :pattern, null: false
t.integer :actions, null: false
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20180608215546_update_billing_columns_on_user.rb | Ruby | apache-2.0 | 187 | the-future | 223 | class UpdateBillingColumnsOnUser < ActiveRecord::Migration[4.2]
def change
remove_column :users, :pro_membership_plan_id
remove_column :users, :stripe_token
remove_column :users, :stripe_customer_id
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161115070551_create_media_follows.rb | Ruby | apache-2.0 | 187 | the-future | 272 | class CreateMediaFollows < ActiveRecord::Migration[4.2]
def change
create_table :media_follows do |t|
t.references :user, null: false, foreign_key: true
t.references :media, null: false, polymorphic: true
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161207194453_use_float_ratings_for_reviews.rb | Ruby | apache-2.0 | 187 | the-future | 276 | class UseFloatRatingsForReviews < ActiveRecord::Migration[4.2]
class Review < ActiveRecord::Base; end
def change
Review.where(rating: 0).update_all(rating: 1)
change_column :reviews, :rating, :float
execute 'UPDATE reviews SET rating = rating / 2.0'
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170602065530_create_media_attribute_votes.rb | Ruby | apache-2.0 | 187 | the-future | 611 | class CreateMediaAttributeVotes < ActiveRecord::Migration[4.2]
def change
create_table :media_attribute_votes do |t|
t.references :user, foreign_key: true, index: true, null: false
t.references :anime_media_attributes
t.references :manga_media_attributes
t.references :dramas_media_attribut... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170414035343_create_site_announcements.rb | Ruby | apache-2.0 | 187 | the-future | 277 | class CreateSiteAnnouncements < ActiveRecord::Migration[4.2]
def change
create_table :site_announcements do |t|
t.references :user, foreign_key: true, null: false
t.text :text, null: true
t.string :link
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161026224944_add_comment_likes.rb | Ruby | apache-2.0 | 187 | the-future | 366 | class AddCommentLikes < ActiveRecord::Migration[4.2]
def change
create_table :comment_likes do |t|
t.references :comment, index: true, foreign_key: true
t.references :user, index: true, foreign_key: true
t.index [:user_id, :comment_id], unique: true
end
add_column :comments, :likes_count... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20181024211956_remove_old_columns_from_quotes.rb | Ruby | apache-2.0 | 187 | the-future | 258 | class RemoveOldColumnsFromQuotes < ActiveRecord::Migration[4.2]
def change
remove_column :quotes, :content, :text, null: false
remove_column :quotes, :character_name, :string, limit: 255
remove_column :quotes, :character_id, :integer
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170215211048_create_group_permissions.rb | Ruby | apache-2.0 | 187 | the-future | 285 | class CreateGroupPermissions < ActiveRecord::Migration[4.2]
def change
create_table :group_permissions do |t|
t.references :group_member, index: true, foreign_key: true, null: false
t.integer :permission, null: false
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161019003515_create_linked_sites.rb | Ruby | apache-2.0 | 187 | the-future | 342 | class CreateLinkedSites < ActiveRecord::Migration[4.2]
def change
create_table :linked_sites do |t|
t.string :name, null: false
t.boolean :share_to, null: false, default: false
t.boolean :share_from, null: false, default: false
t.integer :link_type, null: false
t.timestamps null: fa... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20200603235008_fill_zero_length_on_episodes.rb | Ruby | apache-2.0 | 187 | the-future | 227 | class FillZeroLengthOnEpisodes < ActiveRecord::Migration[5.1]
def change
Episode.where(length: 0).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/20170715053459_create_media_ignores.rb | Ruby | apache-2.0 | 187 | the-future | 273 | class CreateMediaIgnores < ActiveRecord::Migration[4.2]
def change
create_table :media_ignores do |t|
t.references :media, index: true, polymorphic: true
t.references :user, index: true, foreign_key: true
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170429034030_add_watch_dates_to_library_entries.rb | Ruby | apache-2.0 | 187 | the-future | 233 | class AddWatchDatesToLibraryEntries < ActiveRecord::Migration[4.2]
def change
change_table :library_entries do |t|
t.timestamp :started_at
t.timestamp :finished_at
t.timestamp :progressed_at
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20180319230733_add_notification_settings_for_airing.rb | Ruby | apache-2.0 | 187 | the-future | 435 | class AddNotificationSettingsForAiring < ActiveRecord::Migration[4.2]
def change
execute <<-SQL
INSERT INTO notification_settings (
user_id,
setting_type,
fb_messenger_enabled,
mobile_enabled,
email_enabled,
web_enabled,
created_at,
updated_at
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20151213075316_create_drama.rb | Ruby | apache-2.0 | 187 | the-future | 1,301 | class CreateDrama < ActiveRecord::Migration[4.2]
def change
create_table :dramas do |t|
## Title Info
t.string :slug, null: false, index: true
t.hstore :titles, default: {}, null: false
t.string :canonical_title, default: 'ja_en', null: false
t.string :abbreviated_titles, array: true... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20180620015707_replace_billing_service_with_type.rb | Ruby | apache-2.0 | 187 | the-future | 208 | class ReplaceBillingServiceWithType < ActiveRecord::Migration[4.2]
def change
add_column :pro_subscriptions, :type, :string, null: false
remove_column :pro_subscriptions, :billing_service
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20181125234910_make_episode_titles_nullable.rb | Ruby | apache-2.0 | 187 | the-future | 574 | class MakeEpisodeTitlesNullable < ActiveRecord::Migration[4.2]
def up
change_column_null :episodes, :canonical_title, true
change_column_default :episodes, :canonical_title, nil
change_column_null :chapters, :canonical_title, true
change_column_default :chapters, :canonical_title, nil
end
def dow... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170111185104_add_validate_find_and_validate_replace_to_profile_link_site.rb | Ruby | apache-2.0 | 187 | the-future | 234 | class AddValidateFindAndValidateReplaceToProfileLinkSite < ActiveRecord::Migration[4.2]
def change
add_column :profile_link_sites, :validate_find, :string
add_column :profile_link_sites, :validate_replace, :string
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20180722222944_copy_mal_id_to_mappings.rb | Ruby | apache-2.0 | 187 | the-future | 925 | class CopyMALIdToMappings < ActiveRecord::Migration[4.2]
def change
execute <<-SQL.squish
INSERT INTO mappings (
external_site,
external_id,
item_id,
item_type,
created_at,
updated_at
) SELECT
'myanimelist/character' AS external_site,
mal... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20160705041049_create_chapters.rb | Ruby | apache-2.0 | 187 | the-future | 627 | class CreateChapters < ActiveRecord::Migration[4.2]
def change
create_table :chapters do |t|
# belongs_to manga
t.references :manga, index: true
## Title Info
t.hstore :titles, default: {}, null: false
t.string :canonical_title, default: 'en_jp', null: false
## Metadata
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20190603133124_add_email_status_to_users.rb | Ruby | apache-2.0 | 187 | the-future | 350 | require 'update_in_batches'
class AddEmailStatusToUsers < ActiveRecord::Migration[4.2]
using UpdateInBatches
disable_ddl_transaction!
def change
add_column :users, :email_status, :integer, default: 0
say_with_time 'Filling email status' do
User.where.not(confirmed_at: nil).update_in_batches(email... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170601214239_backfill_media_dates.rb | Ruby | apache-2.0 | 187 | the-future | 759 | class BackfillMediaDates < ActiveRecord::Migration[4.2]
using UpdateInBatches
self.disable_ddl_transaction!
def change
Anime.where(episode_count: 1)
.where(start_date: nil)
.where.not(end_date: nil)
.update_in_batches('start_date = end_date')
Anime.where(episode_count: 1)
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170108054725_add_indices_to_library_entries.rb | Ruby | apache-2.0 | 187 | the-future | 324 | class AddIndicesToLibraryEntries < ActiveRecord::Migration[4.2]
self.disable_ddl_transaction!
def change
add_index :library_entries, :anime_id, algorithm: :concurrently
add_index :library_entries, :manga_id, algorithm: :concurrently
add_index :library_entries, :drama_id, algorithm: :concurrently
end
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161029060323_create_blocks.rb | Ruby | apache-2.0 | 187 | the-future | 318 | class CreateBlocks < ActiveRecord::Migration[4.2]
def change
create_table :blocks do |t|
t.references :user, index: true, foreign_key: true, null: false
t.references :blocked, index: true, null: false
t.foreign_key :users, column: 'blocked_id'
t.timestamps null: false
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20171026012230_clean_up_hulu_embed_data.rb | Ruby | apache-2.0 | 187 | the-future | 487 | class CleanUpHuluEmbedData < ActiveRecord::Migration[4.2]
class Video < ActiveRecord::Base; end
class Streamer < ActiveRecord::Base; end
def up
hulu = Streamer.where(site_name: 'Hulu').pluck(:id)
say_with_time 'Cleaning up Hulu embed_data' do
Video.where(streamer_id: hulu).update_all(<<-SQL.squish)... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20181023222601_add_quote_lines.rb | Ruby | apache-2.0 | 187 | the-future | 344 | class AddQuoteLines < ActiveRecord::Migration[4.2]
def change
create_table :quote_lines do |t|
t.references :quote, null: false, index: true
t.references :character, null: false, index: true
t.integer :order, null: false, index: true
t.string :content, null: false
t.timestamps null: ... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20150927002118_add_owner_to_application.rb | Ruby | apache-2.0 | 187 | the-future | 278 | 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 |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170902160628_allow_null_content_for_post_and_comment.rb | Ruby | apache-2.0 | 187 | the-future | 304 | class AllowNullContentForPostAndComment < ActiveRecord::Migration[4.2]
def change
change_column_null :posts, :content, true
change_column_null :posts, :content_formatted, true
change_column_null :comments, :content, true
change_column_null :comments, :content_formatted, true
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161124040820_remove_token_columns_from_user.rb | Ruby | apache-2.0 | 187 | the-future | 279 | class RemoveTokenColumnsFromUser < ActiveRecord::Migration[4.2]
def change
remove_column :users, :confirmation_token
remove_column :users, :confirmation_sent_at
remove_column :users, :reset_password_sent_at
remove_column :users, :reset_password_token
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161102183115_fix_off_by_one_enums.rb | Ruby | apache-2.0 | 187 | the-future | 327 | class FixOffByOneEnums < ActiveRecord::Migration[4.2]
def change
execute <<-SQL.squish
UPDATE anime
SET age_rating = age_rating - 1,
show_type = show_type - 1
SQL
execute <<-SQL.squish
UPDATE manga
SET status = status - 1,
manga_type = manga_type - 1
SQL
e... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20171231030819_add_total_length_to_media.rb | Ruby | apache-2.0 | 187 | the-future | 492 | require 'update_in_batches'
class AddTotalLengthToMedia < ActiveRecord::Migration[4.2]
using UpdateInBatches
def change
add_column :anime, :total_length, :integer
say_with_time 'Backfilling Anime#total_length' do
Anime.all.update_in_batches(<<-SQL.squish, of: 200)
total_length = (
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20241124071050_index_held_reasons.rb | Ruby | apache-2.0 | 187 | the-future | 301 | class IndexHeldReasons < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def change
add_index :posts, :held_reason, algorithm: :concurrently
add_index :comments, :held_reason, algorithm: :concurrently
add_index :media_reactions, :held_reason, algorithm: :concurrently
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170904052311_add_meta_to_attachment_fields_on_models.rb | Ruby | apache-2.0 | 187 | the-future | 721 | class AddMetaToAttachmentFieldsOnModels < ActiveRecord::Migration[4.2]
def change
add_column :anime, :poster_image_meta, :text
add_column :anime, :cover_image_meta, :text
add_column :dramas, :poster_image_meta, :text
add_column :dramas, :cover_image_meta, :text
add_column :manga, :poster_image_m... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170319021941_change_average_rating_column.rb | Ruby | apache-2.0 | 187 | the-future | 315 | class ChangeAverageRatingColumn < ActiveRecord::Migration[4.2]
def change
change_column :anime, :average_rating, :decimal, precision: 5, scale: 2
change_column :manga, :average_rating, :decimal, precision: 5, scale: 2
change_column :dramas, :average_rating, :decimal, precision: 5, scale: 2
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170118222403_fill_manga_age_ratings.rb | Ruby | apache-2.0 | 187 | the-future | 1,189 | require 'update_in_batches'
class FillMangaAgeRatings < ActiveRecord::Migration[4.2]
using UpdateInBatches
self.disable_ddl_transaction!
def up
# Sorted by severity of rating
{
'Kids' => [:G, 'Kids'],
'Harem' => [:PG],
'Gender Bender' => [:PG],
'Romance' =... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20241027084222_add_status_to_units.rb | Ruby | apache-2.0 | 187 | the-future | 424 | class AddStatusToUnits < ActiveRecord::Migration[6.1]
using UpdateInBatches
def change
add_column :chapters, :status, :integer
add_column :episodes, :status, :integer
Chapter.all.update_in_batches(status: 0)
Episode.all.update_in_batches(status: 0)
change_column :chapters, :status, :integer, nu... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20210403025623_add_alternative_order_to_installments.rb | Ruby | apache-2.0 | 187 | the-future | 212 | class AddAlternativeOrderToInstallments < ActiveRecord::Migration[5.2]
def change
add_column :installments, :alternative_order, :integer
rename_column :installments, :position, :release_order
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170726230852_fill_reactions_counter_cache.rb | Ruby | apache-2.0 | 187 | the-future | 268 | require_dependency 'counter_cache_resets'
class FillReactionsCounterCache < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def change
CounterCacheResets.sql_for(User, :media_reactions, where: 'deleted_at IS NULL').each { |sql| execute sql }
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20170311043220_add_first_message_to_tickets.rb | Ruby | apache-2.0 | 187 | the-future | 227 | class AddFirstMessageToTickets < ActiveRecord::Migration[4.2]
def change
add_reference :group_tickets, :first_message
add_foreign_key :group_tickets, :group_ticket_messages,
column: 'first_message_id'
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20161010200413_add_counter_caches_to_posts.rb | Ruby | apache-2.0 | 187 | the-future | 234 | class AddCounterCachesToPosts < ActiveRecord::Migration[4.2]
def change
add_column :posts, :post_likes_count, :integer, null: false, default: 0
add_column :posts, :comments_count, :integer, null: false, default: 0
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | db/migrate/20200809034845_update_new_synopsis_description_field.rb | Ruby | apache-2.0 | 187 | the-future | 589 | class UpdateNewSynopsisDescriptionField < ActiveRecord::Migration[5.1]
def change
Anime.logger = Logger.new(STDERR)
%i(anime episodes manga chapters dramas).each do |model_name|
remove_column model_name, :synopsis
rename_column model_name, :temp_description, :description
end
%i(
am... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.