repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20111207011813_add_email_reconfirmable.rb | db/migrate/20111207011813_add_email_reconfirmable.rb | # frozen_string_literal: true
class AddEmailReconfirmable < ActiveRecord::Migration
def up
add_column :users, :unconfirmed_email, :string
end
def down
remove_column :users, :unconfirmed_email, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20210426172859_add_facebook_meta_tag_to_users.rb | db/migrate/20210426172859_add_facebook_meta_tag_to_users.rb | # frozen_string_literal: true
class AddFacebookMetaTagToUsers < ActiveRecord::Migration[6.1]
def change
add_column :users, :facebook_meta_tag, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120813210705_add_autoban_flag_to_users.rb | db/migrate/20120813210705_add_autoban_flag_to_users.rb | # frozen_string_literal: true
class AddAutobanFlagToUsers < ActiveRecord::Migration
def change
add_column :users, :autoban_flag, :boolean
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20231119190039_drop_delayed_emails.rb | db/migrate/20231119190039_drop_delayed_emails.rb | # frozen_string_literal: true
class DropDelayedEmails < ActiveRecord::Migration[7.0]
def up
drop_table :delayed_emails
end
def down
create_table "delayed_emails", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci" do |t|
t.integer "purchase_id"
t.datetime "created_at", precision: nil
t.datetime "updated_at", precision: nil
t.integer "user_id"
t.string "email_type"
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20220513062810_create_purchase_integration.rb | db/migrate/20220513062810_create_purchase_integration.rb | # frozen_string_literal: true
class CreatePurchaseIntegration < ActiveRecord::Migration[6.1]
def change
create_table :purchase_integrations do |t|
t.bigint :purchase_id, null: false
t.bigint :integration_id, null: false
t.datetime :deleted_at
t.string :discord_user_id
t.timestamps
end
add_index :purchase_integrations, :integration_id
add_index :purchase_integrations, :purchase_id
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20141215091009_add_google_analytics_domains_to_users.rb | db/migrate/20141215091009_add_google_analytics_domains_to_users.rb | # frozen_string_literal: true
class AddGoogleAnalyticsDomainsToUsers < ActiveRecord::Migration
def change
add_column :users, :google_analytics_domains, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20201118135156_remove_unused_users_columns_202011.rb | db/migrate/20201118135156_remove_unused_users_columns_202011.rb | # frozen_string_literal: true
class RemoveUnusedUsersColumns202011 < ActiveRecord::Migration[6.0]
def up
change_table :users do |t|
t.remove :background_video_url
t.remove :number_of_views
t.remove :absorbed_to_user_id
t.remove :beta
t.remove :soundcloud_username
t.remove :soundcloud_token
t.remove :platform_cut
t.remove :ban_flag
t.remove :ban_queued
t.remove :autoban_flag
t.remove :autobanned_at
t.remove :digest_sent_at
t.remove :external_css_url
t.remove :is_developer
t.remove :conversion_tracking_facebook_id
t.remove :conversion_tracking_image_url
end
end
def down
change_table :users do |t|
t.string :background_video_url, limit: 255
t.integer :number_of_views
t.integer :absorbed_to_user_id
t.boolean :beta
t.string :soundcloud_username, limit: 255
t.string :soundcloud_token, limit: 255
t.float :platform_cut
t.boolean :ban_flag
t.boolean :ban_queued
t.boolean :autoban_flag
t.datetime :autobanned_at
t.datetime :digest_sent_at
t.string :external_css_url, limit: 255
t.boolean :is_developer, default: false
t.string :conversion_tracking_facebook_id, limit: 255
t.string :conversion_tracking_image_url, limit: 255
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20230523203442_migrate_deleted_purchases.rb | db/migrate/20230523203442_migrate_deleted_purchases.rb | # frozen_string_literal: true
class MigrateDeletedPurchases < ActiveRecord::Migration[7.0]
def up
return unless Rails.env.development?
invalid_purchase_ids = []
eligible_purchases.find_in_batches do |batch|
batch.each do |purchase|
purchase.update!(
purchase_state: "successful",
is_access_revoked: true
)
rescue StandardError => e
invalid_purchase_ids << { purchase.id => e.message }
end
end
if invalid_purchase_ids.present?
puts("Could not migrate all purchases. Please migrate the following purchases manually")
invalid_purchase_ids.each do |purchase_info|
purchase_info.each { |id, error_message| puts "Purchase ID: #{id}, Error: #{error_message}" }
end
end
end
private
def eligible_purchases
Purchase.where("purchase_state = ?", "deleted")
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20240528131710_add_position_to_bundle_products.rb | db/migrate/20240528131710_add_position_to_bundle_products.rb | # frozen_string_literal: true
class AddPositionToBundleProducts < ActiveRecord::Migration[7.1]
def change
add_column :bundle_products, :position, :integer
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20140528153153_create_twitter_order.rb | db/migrate/20140528153153_create_twitter_order.rb | # frozen_string_literal: true
class CreateTwitterOrder < ActiveRecord::Migration
def change
create_table :twitter_orders do |t|
t.references :purchase
t.string :twitter_order_id
t.integer :order_timestamp, limit: 8
t.string :stripe_transaction_id
t.integer :charge_amount_micro_currency
t.string :charge_state
t.integer :tax_micro_currency
t.string :sku_id
t.string :tax_category
t.integer :sku_price_micro_currency
t.integer :quantity
t.string :twitter_handle
t.string :twitter_user_id
t.string :email
t.string :ip_address
t.string :device_id
t.string :full_name
t.string :street_address_1
t.string :street_address_2
t.string :city
t.string :zip_code
t.string :state
t.string :country
t.integer :tweet_view_timestamp, limit: 8
t.string :tweet_id
t.integer :flags, default: 0, null: false
t.text :json_data
t.timestamps
end
add_index :twitter_orders, :twitter_order_id
add_index :twitter_orders, :sku_id
add_index :twitter_orders, :tweet_id
add_index :twitter_orders, :email
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120305024409_change_description_to_text.rb | db/migrate/20120305024409_change_description_to_text.rb | # frozen_string_literal: true
class ChangeDescriptionToText < ActiveRecord::Migration
def up
change_column :links, :description, :text
end
def down
change_column :links, :description, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20220830182631_remove_links_variants.rb | db/migrate/20220830182631_remove_links_variants.rb | # frozen_string_literal: true
class RemoveLinksVariants < ActiveRecord::Migration[6.1]
def up
remove_column :links, :variants
end
def down
add_column :links, :variants, :text, size: :medium
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20230803151649_add_flags_to_backtax_agreements.rb | db/migrate/20230803151649_add_flags_to_backtax_agreements.rb | # frozen_string_literal: true
class AddFlagsToBacktaxAgreements < ActiveRecord::Migration[7.0]
def change
add_column :backtax_agreements, :flags, :bigint, default: 0, null: false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20170418052305_generate_licenses_for_existing_customers.rb | db/migrate/20170418052305_generate_licenses_for_existing_customers.rb | # frozen_string_literal: true
class GenerateLicensesForExistingCustomers < ActiveRecord::Migration
def change
# Commented out as it is taking too long to run on production.
# Link.is_licensed.find_each do |link|
# CreateLicensesForExistingCustomers.perform(link.id)
# end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20150921173816_add_default_value_to_licenses_flag.rb | db/migrate/20150921173816_add_default_value_to_licenses_flag.rb | # frozen_string_literal: true
class AddDefaultValueToLicensesFlag < ActiveRecord::Migration
def up
change_column :licenses, :flags, :integer, default: 0
end
def down
change_column :licenses, :flags, :integer, default: nil
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20201008081331_add_tax_and_fee_to_purchase_index.rb | db/migrate/20201008081331_add_tax_and_fee_to_purchase_index.rb | # frozen_string_literal: true
class AddTaxAndFeeToPurchaseIndex < ActiveRecord::Migration[6.0]
def up
Elasticsearch::Model.client.indices.put_mapping(
index: "purchases_v2",
type: "purchase",
body: {
purchase: {
properties: {
fee_cents: { type: "long" },
tax_cents: { type: "long" }
}
}
}
)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20230502015838_add_better_url_redirects_post_indexes.rb | db/migrate/20230502015838_add_better_url_redirects_post_indexes.rb | # frozen_string_literal: true
class AddBetterUrlRedirectsPostIndexes < ActiveRecord::Migration[7.0]
def change
change_table :url_redirects, bulk: true do |t|
t.index [:installment_id, :purchase_id]
t.index [:installment_id, :subscription_id]
t.index [:installment_id, :imported_customer_id]
t.remove_index :installment_id
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20150331074645_rename_fields_and_add_deleted_at_to_shipping_destinations.rb | db/migrate/20150331074645_rename_fields_and_add_deleted_at_to_shipping_destinations.rb | # frozen_string_literal: true
class RenameFieldsAndAddDeletedAtToShippingDestinations < ActiveRecord::Migration
def change
add_column :shipping_destinations, :deleted_at, :datetime
rename_column :shipping_destinations, :country_code2, :country_code
rename_column :shipping_destinations, :standalone_rate_cents, :one_item_rate_cents
rename_column :shipping_destinations, :combined_rate_cents, :multiple_items_rate_cents
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20240507135935_add_index_on_carts_updated_at.rb | db/migrate/20240507135935_add_index_on_carts_updated_at.rb | # frozen_string_literal: true
class AddIndexOnCartsUpdatedAt < ActiveRecord::Migration[7.1]
def change
add_index :carts, :updated_at
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20121130222908_add_cleaned_referrer_to_events.rb | db/migrate/20121130222908_add_cleaned_referrer_to_events.rb | # frozen_string_literal: true
class AddCleanedReferrerToEvents < ActiveRecord::Migration
def change
add_column :events, :referrer_domain, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20230420160357_create_refund_policies.rb | db/migrate/20230420160357_create_refund_policies.rb | # frozen_string_literal: true
class CreateRefundPolicies < ActiveRecord::Migration[7.0]
def change
create_table :refund_policies do |t|
t.references :seller, index: true, null: false
t.references :product, index: { unique: true }, null: false
t.string :title, null: false
t.text :fine_print
t.timestamps
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20140120021811_add_flags_to_transcoded_videos.rb | db/migrate/20140120021811_add_flags_to_transcoded_videos.rb | # frozen_string_literal: true
class AddFlagsToTranscodedVideos < ActiveRecord::Migration
def change
add_column :transcoded_videos, :flags, :integer, default: 0, null: false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20231115001459_create_bundle_product_purchases.rb | db/migrate/20231115001459_create_bundle_product_purchases.rb | # frozen_string_literal: true
class CreateBundleProductPurchases < ActiveRecord::Migration[7.0]
def change
create_table :bundle_product_purchases do |t|
t.references :bundle_purchase, null: false
t.references :product_purchase, null: false
t.timestamps
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20130211200121_create_ab_tests_table.rb | db/migrate/20130211200121_create_ab_tests_table.rb | # frozen_string_literal: true
class CreateAbTestsTable < ActiveRecord::Migration
def change
create_table :ab_tests do |t|
t.string :name
t.string :page_name
t.boolean :is_active, default: false
t.datetime "deleted_at"
t.timestamps
end
add_index "ab_tests", ["name", "page_name"], name: "index_ab_tests_on_name_and_page_name"
add_index "ab_tests", "page_name", name: "index_ab_tests_on_page_name"
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20230330021302_add_microseconds_to_products_updated_at.rb | db/migrate/20230330021302_add_microseconds_to_products_updated_at.rb | # frozen_string_literal: true
class AddMicrosecondsToProductsUpdatedAt < ActiveRecord::Migration[7.0]
def up
change_column :links, :updated_at, :datetime, precision: 6
end
def down
change_column :links, :updated_at, :datetime, precision: nil
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20111122002403_create_receipts.rb | db/migrate/20111122002403_create_receipts.rb | # frozen_string_literal: true
class CreateReceipts < ActiveRecord::Migration
def change
create_table :receipts do |t|
t.text :email
t.integer :purchase_id
t.timestamps
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20220413003135_add_taxonomy_id_to_product_index.rb | db/migrate/20220413003135_add_taxonomy_id_to_product_index.rb | # frozen_string_literal: true
class AddTaxonomyIdToProductIndex < ActiveRecord::Migration[6.1]
def up
EsClient.indices.put_mapping(
index: Link.index_name,
body: {
properties: {
taxonomy_id: { type: "long" }
}
}
)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120510202146_add_stripe_card_attributes_to_credit_cards.rb | db/migrate/20120510202146_add_stripe_card_attributes_to_credit_cards.rb | # frozen_string_literal: true
class AddStripeCardAttributesToCreditCards < ActiveRecord::Migration
def change
add_column :credit_cards, :cvc_check, :boolean
add_column :credit_cards, :card_country, :string
add_column :credit_cards, :stripe_card_id, :string
rename_column :credit_cards, :stripe_id, :stripe_customer_id
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20250406055017_add_index_to_followers_table.rb | db/migrate/20250406055017_add_index_to_followers_table.rb | # frozen_string_literal: true
class AddIndexToFollowersTable < ActiveRecord::Migration[7.1]
def change
change_table :followers, bulk: true do |t|
t.index [:followed_id, :confirmed_at]
t.remove_index [:followed_id, :follower_user_id]
t.remove_index [:follower_user_id, :followed_id]
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120226203453_add_width_to_infos.rb | db/migrate/20120226203453_add_width_to_infos.rb | # frozen_string_literal: true
class AddWidthToInfos < ActiveRecord::Migration
def change
add_column :infos, :width, :integer
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20111109220139_links_missing_attr.rb | db/migrate/20111109220139_links_missing_attr.rb | # frozen_string_literal: true
class LinksMissingAttr < ActiveRecord::Migration
def up
add_column :links, :owner, :string
add_column :links, :length_of_exclusivity, :integer
add_column :links, :create_date, :integer
end
def down
remove_column :links, :owner
remove_column :links, :length_of_exclusivity
remove_column :links, :create_date
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20111212221158_remove_unique_index_on_email.rb | db/migrate/20111212221158_remove_unique_index_on_email.rb | # frozen_string_literal: true
class RemoveUniqueIndexOnEmail < ActiveRecord::Migration
def up
remove_index :users, :email
add_index :users, :email
end
def down
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20220322122601_add_financing_paydown_purchase_id_to_credits.rb | db/migrate/20220322122601_add_financing_paydown_purchase_id_to_credits.rb | # frozen_string_literal: true
class AddFinancingPaydownPurchaseIdToCredits < ActiveRecord::Migration[6.1]
def change
add_column :credits, :financing_paydown_purchase_id, :integer
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20240409134857_remove_email_from_carts.rb | db/migrate/20240409134857_remove_email_from_carts.rb | # frozen_string_literal: true
class RemoveEmailFromCarts < ActiveRecord::Migration[7.1]
def change
remove_column :carts, :email, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20210920213746_add_product_and_seller_names_to_purchase_mapping.rb | db/migrate/20210920213746_add_product_and_seller_names_to_purchase_mapping.rb | # frozen_string_literal: true
class AddProductAndSellerNamesToPurchaseMapping < ActiveRecord::Migration[6.1]
def up
EsClient.indices.close(index: Purchase.index_name)
EsClient.indices.put_settings(
index: Purchase.index_name,
body: {
settings: {
index: {
analysis: {
filter: {
full_autocomplete_filter: {
type: "edge_ngram",
min_gram: 1,
max_gram: 20
}
},
analyzer: {
product_name: {
tokenizer: "whitespace",
filter: ["lowercase", "full_autocomplete_filter"]
},
search_product_name: {
tokenizer: "whitespace",
filter: "lowercase"
}
}
}
}
}
}
)
EsClient.indices.open(index: Purchase.index_name)
EsClient.indices.put_mapping(
index: Purchase.index_name,
body: {
properties: {
seller: {
type: :nested,
properties: {
name: { type: :text, analyzer: :full_name, search_analyzer: :search_full_name }
}
},
product: {
type: :nested,
properties: {
name: { type: :text, analyzer: :product_name, search_analyzer: :search_product_name },
description: { type: :text }
}
}
}
}
)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20240409154638_add_flags_to_charges.rb | db/migrate/20240409154638_add_flags_to_charges.rb | # frozen_string_literal: true
class AddFlagsToCharges < ActiveRecord::Migration[7.1]
def change
add_column :charges, :flags, :bigint, default: 0, null: false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20240803055758_drop_processed_audios.rb | db/migrate/20240803055758_drop_processed_audios.rb | # frozen_string_literal: true
class DropProcessedAudios < ActiveRecord::Migration[7.1]
def up
drop_table :processed_audios
end
def down
create_table "processed_audios", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.integer "product_file_id"
t.string "url", limit: 1024
t.datetime "created_at", precision: nil
t.datetime "updated_at", precision: nil
t.datetime "deleted_at", precision: nil
t.index ["product_file_id"], name: "index_processed_audios_on_product_file_id"
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20191121171504_add_app_type_to_device.rb | db/migrate/20191121171504_add_app_type_to_device.rb | # frozen_string_literal: true
class AddAppTypeToDevice < ActiveRecord::Migration
def up
add_column :devices, :app_type, :string, null: false, limit: 255
change_column_default :devices, :app_type, "consumer"
add_index :devices, [:app_type, :user_id]
end
def down
remove_column :devices, :app_type
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20190910183718_backfill_installments_with_email_channel.rb | db/migrate/20190910183718_backfill_installments_with_email_channel.rb | # frozen_string_literal: true
class BackfillInstallmentsWithEmailChannel < ActiveRecord::Migration
def up
Installment.find_in_batches do |installments|
installments.each do |installment|
installment.send_emails = true
installment.save!
end
sleep(0.05)
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20191105224621_add_index_on_users_for_twitter_o_auth_token.rb | db/migrate/20191105224621_add_index_on_users_for_twitter_o_auth_token.rb | # frozen_string_literal: true
class AddIndexOnUsersForTwitterOAuthToken < ActiveRecord::Migration
def up
add_index :users, :twitter_oauth_token
end
def down
remove_index :users, :twitter_oauth_token
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20221017161900_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb | db/migrate/20221017161900_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb | # frozen_string_literal: true
# This migration comes from active_storage (originally 20211119233751)
class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
def change
Alterity.disable do
change_column_null(:active_storage_blobs, :checksum, true)
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20231003201734_add_additional_fields_to_dispute_evidences.rb | db/migrate/20231003201734_add_additional_fields_to_dispute_evidences.rb | # frozen_string_literal: true
class AddAdditionalFieldsToDisputeEvidences < ActiveRecord::Migration[7.0]
def change
change_table :dispute_evidences, bulk: true do |t|
t.text :cancellation_rebuttal
t.text :refund_refusal_explanation
t.datetime :seller_contacted_at
t.datetime :seller_submitted_at
t.index :submitted_at
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20130415204908_add_flags_to_url_redirects.rb | db/migrate/20130415204908_add_flags_to_url_redirects.rb | # frozen_string_literal: true
class AddFlagsToUrlRedirects < ActiveRecord::Migration
def change
add_column :url_redirects, :flags, :integer, default: 0, null: false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20121115042531_remove_event_name_index_on_events.rb | db/migrate/20121115042531_remove_event_name_index_on_events.rb | # frozen_string_literal: true
class RemoveEventNameIndexOnEvents < ActiveRecord::Migration
def up
remove_index "events", "event_type"
end
def down
add_index "events", "event_type"
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20141203200306_create_installment_rules.rb | db/migrate/20141203200306_create_installment_rules.rb | # frozen_string_literal: true
class CreateInstallmentRules < ActiveRecord::Migration
def change
create_table :installment_rules do |t|
t.integer :installment_id
t.integer :relative_delivery_time
t.datetime :to_be_published_at
t.integer :version, default: 0, null: false
t.datetime :deleted_at
t.timestamps
end
add_index :installment_rules, [:installment_id], unique: true
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20200514132253_add_customizable_prices_for_variants.rb | db/migrate/20200514132253_add_customizable_prices_for_variants.rb | # frozen_string_literal: true
class AddCustomizablePricesForVariants < ActiveRecord::Migration[5.1]
def up
add_column :base_variants, :customizable_price, :boolean
add_column :prices, :suggested_price_cents, :integer
end
def down
remove_column :prices, :suggested_price_cents
remove_column :base_variants, :customizable_price
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20130531221758_add_index_on_email_and_followed_id_to_follows.rb | db/migrate/20130531221758_add_index_on_email_and_followed_id_to_follows.rb | # frozen_string_literal: true
class AddIndexOnEmailAndFollowedIdToFollows < ActiveRecord::Migration
def change
add_index :follows, [:email, :followed_id]
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20191201174402_add_rental_expired_to_purchases.rb | db/migrate/20191201174402_add_rental_expired_to_purchases.rb | # frozen_string_literal: true
class AddRentalExpiredToPurchases < ActiveRecord::Migration
def up
add_column :purchases, :rental_expired, :boolean
add_index :purchases, :rental_expired
end
def down
remove_column :purchases, :rental_expired
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20220218020712_add_slugs_to_taxonomies.rb | db/migrate/20220218020712_add_slugs_to_taxonomies.rb | # frozen_string_literal: true
class AddSlugsToTaxonomies < ActiveRecord::Migration[6.1]
def change
add_column :taxonomies, :slug, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20121115041918_add_composite_event_name_link_id_index_on_events.rb | db/migrate/20121115041918_add_composite_event_name_link_id_index_on_events.rb | # frozen_string_literal: true
class AddCompositeEventNameLinkIdIndexOnEvents < ActiveRecord::Migration
def up
add_index "events", ["event_name", "link_id"]
end
def down
remove_index "events", ["event_name", "link_id"]
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20250211173413_increase_utm_link_param_char_limits.rb | db/migrate/20250211173413_increase_utm_link_param_char_limits.rb | # frozen_string_literal: true
class IncreaseUtmLinkParamCharLimits < ActiveRecord::Migration[7.1]
def up
change_table :utm_links, bulk: true do |t|
t.remove_index name: "index_utm_links_on_utm_fields_and_target_resource"
t.change :utm_campaign, :string, limit: 200
t.change :utm_medium, :string, limit: 200
t.change :utm_source, :string, limit: 200
t.change :utm_term, :string, limit: 200
t.change :utm_content, :string, limit: 200
t.index [:seller_id, :utm_source, :utm_medium, :utm_campaign, :utm_term, :utm_content, :target_resource_type, :target_resource_id], where: "deleted_at IS NULL", name: "index_utm_links_on_utm_fields_and_target_resource", unique: true, length: { utm_campaign: 100, utm_medium: 100, utm_source: 100, utm_term: 100, utm_content: 100 }
end
end
def down
change_table :utm_links, bulk: true do |t|
t.remove_index name: "index_utm_links_on_utm_fields_and_target_resource"
t.change :utm_campaign, :string, limit: 64
t.change :utm_medium, :string, limit: 64
t.change :utm_source, :string, limit: 64
t.change :utm_term, :string, limit: 64
t.change :utm_content, :string, limit: 64
t.index [:seller_id, :utm_source, :utm_medium, :utm_campaign, :utm_term, :utm_content, :target_resource_type, :target_resource_id], where: "deleted_at IS NULL", name: "index_utm_links_on_utm_fields_and_target_resource", unique: true
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120528234113_add_state_to_users.rb | db/migrate/20120528234113_add_state_to_users.rb | # frozen_string_literal: true
class AddStateToUsers < ActiveRecord::Migration
def change
add_column :users, :state, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120226203552_remove_resolution_from_infos.rb | db/migrate/20120226203552_remove_resolution_from_infos.rb | # frozen_string_literal: true
class RemoveResolutionFromInfos < ActiveRecord::Migration
def up
remove_column :infos, :resolution
end
def down
add_column :infos, :resolution, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20230503202309_add_purchase_refund_policies.rb | db/migrate/20230503202309_add_purchase_refund_policies.rb | # frozen_string_literal: true
class AddPurchaseRefundPolicies < ActiveRecord::Migration[7.0]
def change
create_table :purchase_refund_policies do |t|
t.references :purchase, index: true, null: false
t.string :title, null: false
t.text :fine_print
t.timestamps
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20111212220615_user_facebook_uid.rb | db/migrate/20111212220615_user_facebook_uid.rb | # frozen_string_literal: true
class UserFacebookUid < ActiveRecord::Migration
def up
add_column :users, :facebook_uid, :string
add_index :users, :facebook_uid
end
def down
remove_index :users, :facebook_uid
remove_column :users, :facebook_uid, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20181031091727_create_product_reviews.rb | db/migrate/20181031091727_create_product_reviews.rb | # frozen_string_literal: true
class CreateProductReviews < ActiveRecord::Migration
def change
create_table :product_reviews do |t|
t.references :purchase, index: true, unique: true, foreign_key: { on_delete: :cascade }
t.integer :rating, default: nil
t.timestamps null: false
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20230310211434_add_affiliate_basis_points_to_affiliates_links.rb | db/migrate/20230310211434_add_affiliate_basis_points_to_affiliates_links.rb | # frozen_string_literal: true
class AddAffiliateBasisPointsToAffiliatesLinks < ActiveRecord::Migration[7.0]
def change
add_column :affiliates_links, :affiliate_basis_points, :integer
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20220518034006_create_product_cached_values.rb | db/migrate/20220518034006_create_product_cached_values.rb | # frozen_string_literal: true
class CreateProductCachedValues < ActiveRecord::Migration[6.1]
def change
create_table :product_cached_values do |t|
t.bigint :product_id, null: false, index: true
t.boolean :expired, default: false, null: false, index: true
t.integer :successful_sales_count
t.integer :remaining_for_sale_count
t.decimal :monthly_recurring_revenue, precision: 10, scale: 2
t.decimal :revenue_pending, precision: 10, scale: 2
t.timestamps
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120516194950_remove_balance_cents_from_links.rb | db/migrate/20120516194950_remove_balance_cents_from_links.rb | # frozen_string_literal: true
class RemoveBalanceCentsFromLinks < ActiveRecord::Migration
def up
remove_column :links, :balance_cents
end
def down
add_column :links, :balance_cents, :integer
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20240928021005_add_past_year_fee_cents_to_products_index.rb | db/migrate/20240928021005_add_past_year_fee_cents_to_products_index.rb | # frozen_string_literal: true
class AddPastYearFeeCentsToProductsIndex < ActiveRecord::Migration[7.1]
def up
EsClient.indices.put_mapping(
index: Link.index_name,
body: {
properties: {
past_year_fee_cents: { type: "long" },
}
}
)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120426222453_add_tags_to_infos.rb | db/migrate/20120426222453_add_tags_to_infos.rb | # frozen_string_literal: true
class AddTagsToInfos < ActiveRecord::Migration
def change
add_column :infos, :tags, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20240616210250_remove_sales_stats_tables.rb | db/migrate/20240616210250_remove_sales_stats_tables.rb | # frozen_string_literal: true
class RemoveSalesStatsTables < ActiveRecord::Migration[7.1]
def up
drop_table :product_daily_sales_stats, if_exists: true
drop_table :product_sales_stats, if_exists: true
drop_table :seller_daily_sales_stats, if_exists: true
drop_table :seller_sales_stats, if_exists: true
drop_table :variant_daily_sales_stats, if_exists: true
drop_table :variant_sales_stats, if_exists: true
end
def down
create_table "product_daily_sales_stats", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: true do |t|
t.bigint "seller_id", null: false
t.bigint "product_id", null: false
t.date "date", null: false
t.bigint "sales_cents", default: 0, null: false
t.bigint "refunds_cents", default: 0, null: false
t.bigint "disputes_cents", default: 0, null: false
t.bigint "dispute_reversals_cents", default: 0, null: false
t.virtual "net_revenue_cents", type: :bigint, null: false, as: "(((`sales_cents` - `refunds_cents`) - `disputes_cents`) + `dispute_reversals_cents`)", stored: true
t.bigint "fees_cents", default: 0, null: false
t.bigint "fees_refunds_cents", default: 0, null: false
t.bigint "fees_disputes_cents", default: 0, null: false
t.bigint "fees_dispute_reversals_cents", default: 0, null: false
t.virtual "net_fees_cents", type: :bigint, null: false, as: "(((`fees_cents` - `fees_refunds_cents`) - `fees_disputes_cents`) + `fees_dispute_reversals_cents`)", stored: true
t.bigint "affiliate_sales_cents", default: 0, null: false
t.bigint "affiliate_refunds_cents", default: 0, null: false
t.bigint "affiliate_disputes_cents", default: 0, null: false
t.bigint "affiliate_dispute_reversals_cents", default: 0, null: false
t.virtual "net_affiliate_revenue_cents", type: :bigint, null: false, as: "(((`affiliate_sales_cents` - `affiliate_refunds_cents`) - `affiliate_disputes_cents`) + `affiliate_dispute_reversals_cents`)", stored: true
t.virtual "adjusted_net_revenue_cents", type: :bigint, null: false, as: "((`net_revenue_cents` - `net_fees_cents`) - `net_affiliate_revenue_cents`)", stored: true
t.bigint "discover_sales_cents", default: 0, null: false
t.bigint "discover_refunds_cents", default: 0, null: false
t.bigint "discover_disputes_cents", default: 0, null: false
t.bigint "discover_dispute_reversals_cents", default: 0, null: false
t.virtual "discover_net_revenue_cents", type: :bigint, null: false, as: "(((`discover_sales_cents` - `discover_refunds_cents`) - `discover_disputes_cents`) + `discover_dispute_reversals_cents`)", stored: true
t.integer "sales_count", default: 0, null: false
t.integer "full_refunds_count", default: 0, null: false
t.integer "disputes_count", default: 0, null: false
t.integer "dispute_reversals_count", default: 0, null: false
t.virtual "net_sales_count", type: :integer, null: false, as: "(((`sales_count` - `full_refunds_count`) - `disputes_count`) + `dispute_reversals_count`)", stored: true
t.integer "free_sales_count", default: 0, null: false
t.integer "active_nonmemberships_count", default: 0, null: false
t.integer "inactive_nonmemberships_count", default: 0, null: false
t.virtual "net_active_nonmemberships_count", type: :integer, null: false, as: "(`active_nonmemberships_count` - `inactive_nonmemberships_count`)", stored: true
t.integer "active_memberships_count", default: 0, null: false
t.integer "inactive_memberships_count", default: 0, null: false
t.virtual "net_active_memberships_count", type: :integer, null: false, as: "(`active_memberships_count` - `inactive_memberships_count`)", stored: true
t.virtual "net_active_sales_count", type: :integer, null: false, as: "(`net_active_nonmemberships_count` + `net_active_memberships_count`)", stored: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["date"], name: "index_product_daily_sales_stats_on_date"
t.index ["product_id", "date"], name: "index_product_daily_sales_stats_on_product_id_and_date", unique: true
t.index ["seller_id", "date"], name: "index_product_daily_sales_stats_on_seller_id_and_date"
end
create_table "product_sales_stats", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: true do |t|
t.bigint "seller_id", null: false
t.bigint "product_id", null: false
t.bigint "sales_cents", default: 0, null: false
t.bigint "refunds_cents", default: 0, null: false
t.bigint "disputes_cents", default: 0, null: false
t.bigint "dispute_reversals_cents", default: 0, null: false
t.virtual "net_revenue_cents", type: :bigint, null: false, as: "(((`sales_cents` - `refunds_cents`) - `disputes_cents`) + `dispute_reversals_cents`)", stored: true
t.bigint "fees_cents", default: 0, null: false
t.bigint "fees_refunds_cents", default: 0, null: false
t.bigint "fees_disputes_cents", default: 0, null: false
t.bigint "fees_dispute_reversals_cents", default: 0, null: false
t.virtual "net_fees_cents", type: :bigint, null: false, as: "(((`fees_cents` - `fees_refunds_cents`) - `fees_disputes_cents`) + `fees_dispute_reversals_cents`)", stored: true
t.bigint "affiliate_sales_cents", default: 0, null: false
t.bigint "affiliate_refunds_cents", default: 0, null: false
t.bigint "affiliate_disputes_cents", default: 0, null: false
t.bigint "affiliate_dispute_reversals_cents", default: 0, null: false
t.virtual "net_affiliate_revenue_cents", type: :bigint, null: false, as: "(((`affiliate_sales_cents` - `affiliate_refunds_cents`) - `affiliate_disputes_cents`) + `affiliate_dispute_reversals_cents`)", stored: true
t.virtual "adjusted_net_revenue_cents", type: :bigint, null: false, as: "((`net_revenue_cents` - `net_fees_cents`) - `net_affiliate_revenue_cents`)", stored: true
t.bigint "discover_sales_cents", default: 0, null: false
t.bigint "discover_refunds_cents", default: 0, null: false
t.bigint "discover_disputes_cents", default: 0, null: false
t.bigint "discover_dispute_reversals_cents", default: 0, null: false
t.virtual "discover_net_revenue_cents", type: :bigint, null: false, as: "(((`discover_sales_cents` - `discover_refunds_cents`) - `discover_disputes_cents`) + `discover_dispute_reversals_cents`)", stored: true
t.integer "sales_count", default: 0, null: false
t.integer "full_refunds_count", default: 0, null: false
t.integer "disputes_count", default: 0, null: false
t.integer "dispute_reversals_count", default: 0, null: false
t.virtual "net_sales_count", type: :integer, null: false, as: "(((`sales_count` - `full_refunds_count`) - `disputes_count`) + `dispute_reversals_count`)", stored: true
t.integer "free_sales_count", default: 0, null: false
t.integer "active_nonmemberships_count", default: 0, null: false
t.integer "inactive_nonmemberships_count", default: 0, null: false
t.virtual "net_active_nonmemberships_count", type: :integer, null: false, as: "(`active_nonmemberships_count` - `inactive_nonmemberships_count`)", stored: true
t.integer "active_memberships_count", default: 0, null: false
t.integer "inactive_memberships_count", default: 0, null: false
t.virtual "net_active_memberships_count", type: :integer, null: false, as: "(`active_memberships_count` - `inactive_memberships_count`)", stored: true
t.virtual "net_active_sales_count", type: :integer, null: false, as: "(`net_active_nonmemberships_count` + `net_active_memberships_count`)", stored: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["product_id"], name: "index_product_sales_stats_on_product_id", unique: true
t.index ["seller_id"], name: "index_product_sales_stats_on_seller_id"
end
create_table "seller_daily_sales_stats", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: true do |t|
t.bigint "seller_id", null: false
t.date "date", null: false
t.bigint "sales_cents", default: 0, null: false
t.bigint "refunds_cents", default: 0, null: false
t.bigint "disputes_cents", default: 0, null: false
t.bigint "dispute_reversals_cents", default: 0, null: false
t.virtual "net_revenue_cents", type: :bigint, null: false, as: "(((`sales_cents` - `refunds_cents`) - `disputes_cents`) + `dispute_reversals_cents`)", stored: true
t.bigint "fees_cents", default: 0, null: false
t.bigint "fees_refunds_cents", default: 0, null: false
t.bigint "fees_disputes_cents", default: 0, null: false
t.bigint "fees_dispute_reversals_cents", default: 0, null: false
t.virtual "net_fees_cents", type: :bigint, null: false, as: "(((`fees_cents` - `fees_refunds_cents`) - `fees_disputes_cents`) + `fees_dispute_reversals_cents`)", stored: true
t.bigint "affiliate_sales_cents", default: 0, null: false
t.bigint "affiliate_refunds_cents", default: 0, null: false
t.bigint "affiliate_disputes_cents", default: 0, null: false
t.bigint "affiliate_dispute_reversals_cents", default: 0, null: false
t.virtual "net_affiliate_revenue_cents", type: :bigint, null: false, as: "(((`affiliate_sales_cents` - `affiliate_refunds_cents`) - `affiliate_disputes_cents`) + `affiliate_dispute_reversals_cents`)", stored: true
t.virtual "adjusted_net_revenue_cents", type: :bigint, null: false, as: "((`net_revenue_cents` - `net_fees_cents`) - `net_affiliate_revenue_cents`)", stored: true
t.bigint "discover_sales_cents", default: 0, null: false
t.bigint "discover_refunds_cents", default: 0, null: false
t.bigint "discover_disputes_cents", default: 0, null: false
t.bigint "discover_dispute_reversals_cents", default: 0, null: false
t.virtual "discover_net_revenue_cents", type: :bigint, null: false, as: "(((`discover_sales_cents` - `discover_refunds_cents`) - `discover_disputes_cents`) + `discover_dispute_reversals_cents`)", stored: true
t.integer "sales_count", default: 0, null: false
t.integer "full_refunds_count", default: 0, null: false
t.integer "disputes_count", default: 0, null: false
t.integer "dispute_reversals_count", default: 0, null: false
t.virtual "net_sales_count", type: :integer, null: false, as: "(((`sales_count` - `full_refunds_count`) - `disputes_count`) + `dispute_reversals_count`)", stored: true
t.integer "free_sales_count", default: 0, null: false
t.integer "active_nonmemberships_count", default: 0, null: false
t.integer "inactive_nonmemberships_count", default: 0, null: false
t.virtual "net_active_nonmemberships_count", type: :integer, null: false, as: "(`active_nonmemberships_count` - `inactive_nonmemberships_count`)", stored: true
t.integer "active_memberships_count", default: 0, null: false
t.integer "inactive_memberships_count", default: 0, null: false
t.virtual "net_active_memberships_count", type: :integer, null: false, as: "(`active_memberships_count` - `inactive_memberships_count`)", stored: true
t.virtual "net_active_sales_count", type: :integer, null: false, as: "(`net_active_nonmemberships_count` + `net_active_memberships_count`)", stored: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["date"], name: "index_seller_daily_sales_stats_on_date"
t.index ["seller_id", "date"], name: "index_seller_daily_sales_stats_on_seller_id_and_date", unique: true
end
create_table "seller_sales_stats", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: true do |t|
t.bigint "seller_id", null: false
t.bigint "sales_cents", default: 0, null: false
t.bigint "refunds_cents", default: 0, null: false
t.bigint "disputes_cents", default: 0, null: false
t.bigint "dispute_reversals_cents", default: 0, null: false
t.virtual "net_revenue_cents", type: :bigint, null: false, as: "(((`sales_cents` - `refunds_cents`) - `disputes_cents`) + `dispute_reversals_cents`)", stored: true
t.bigint "fees_cents", default: 0, null: false
t.bigint "fees_refunds_cents", default: 0, null: false
t.bigint "fees_disputes_cents", default: 0, null: false
t.bigint "fees_dispute_reversals_cents", default: 0, null: false
t.virtual "net_fees_cents", type: :bigint, null: false, as: "(((`fees_cents` - `fees_refunds_cents`) - `fees_disputes_cents`) + `fees_dispute_reversals_cents`)", stored: true
t.bigint "affiliate_sales_cents", default: 0, null: false
t.bigint "affiliate_refunds_cents", default: 0, null: false
t.bigint "affiliate_disputes_cents", default: 0, null: false
t.bigint "affiliate_dispute_reversals_cents", default: 0, null: false
t.virtual "net_affiliate_revenue_cents", type: :bigint, null: false, as: "(((`affiliate_sales_cents` - `affiliate_refunds_cents`) - `affiliate_disputes_cents`) + `affiliate_dispute_reversals_cents`)", stored: true
t.virtual "adjusted_net_revenue_cents", type: :bigint, null: false, as: "((`net_revenue_cents` - `net_fees_cents`) - `net_affiliate_revenue_cents`)", stored: true
t.bigint "discover_sales_cents", default: 0, null: false
t.bigint "discover_refunds_cents", default: 0, null: false
t.bigint "discover_disputes_cents", default: 0, null: false
t.bigint "discover_dispute_reversals_cents", default: 0, null: false
t.virtual "discover_net_revenue_cents", type: :bigint, null: false, as: "(((`discover_sales_cents` - `discover_refunds_cents`) - `discover_disputes_cents`) + `discover_dispute_reversals_cents`)", stored: true
t.integer "sales_count", default: 0, null: false
t.integer "full_refunds_count", default: 0, null: false
t.integer "disputes_count", default: 0, null: false
t.integer "dispute_reversals_count", default: 0, null: false
t.virtual "net_sales_count", type: :integer, null: false, as: "(((`sales_count` - `full_refunds_count`) - `disputes_count`) + `dispute_reversals_count`)", stored: true
t.integer "free_sales_count", default: 0, null: false
t.integer "active_nonmemberships_count", default: 0, null: false
t.integer "inactive_nonmemberships_count", default: 0, null: false
t.virtual "net_active_nonmemberships_count", type: :integer, null: false, as: "(`active_nonmemberships_count` - `inactive_nonmemberships_count`)", stored: true
t.integer "active_memberships_count", default: 0, null: false
t.integer "inactive_memberships_count", default: 0, null: false
t.virtual "net_active_memberships_count", type: :integer, null: false, as: "(`active_memberships_count` - `inactive_memberships_count`)", stored: true
t.virtual "net_active_sales_count", type: :integer, null: false, as: "(`net_active_nonmemberships_count` + `net_active_memberships_count`)", stored: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["seller_id"], name: "index_seller_sales_stats_on_seller_id", unique: true
end
create_table "variant_daily_sales_stats", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: true do |t|
t.bigint "seller_id", null: false
t.bigint "product_id", null: false
t.bigint "variant_id", null: false
t.date "date", null: false
t.bigint "sales_cents", default: 0, null: false
t.bigint "refunds_cents", default: 0, null: false
t.bigint "disputes_cents", default: 0, null: false
t.bigint "dispute_reversals_cents", default: 0, null: false
t.virtual "net_revenue_cents", type: :bigint, null: false, as: "(((`sales_cents` - `refunds_cents`) - `disputes_cents`) + `dispute_reversals_cents`)", stored: true
t.bigint "fees_cents", default: 0, null: false
t.bigint "fees_refunds_cents", default: 0, null: false
t.bigint "fees_disputes_cents", default: 0, null: false
t.bigint "fees_dispute_reversals_cents", default: 0, null: false
t.virtual "net_fees_cents", type: :bigint, null: false, as: "(((`fees_cents` - `fees_refunds_cents`) - `fees_disputes_cents`) + `fees_dispute_reversals_cents`)", stored: true
t.bigint "affiliate_sales_cents", default: 0, null: false
t.bigint "affiliate_refunds_cents", default: 0, null: false
t.bigint "affiliate_disputes_cents", default: 0, null: false
t.bigint "affiliate_dispute_reversals_cents", default: 0, null: false
t.virtual "net_affiliate_revenue_cents", type: :bigint, null: false, as: "(((`affiliate_sales_cents` - `affiliate_refunds_cents`) - `affiliate_disputes_cents`) + `affiliate_dispute_reversals_cents`)", stored: true
t.virtual "adjusted_net_revenue_cents", type: :bigint, null: false, as: "((`net_revenue_cents` - `net_fees_cents`) - `net_affiliate_revenue_cents`)", stored: true
t.bigint "discover_sales_cents", default: 0, null: false
t.bigint "discover_refunds_cents", default: 0, null: false
t.bigint "discover_disputes_cents", default: 0, null: false
t.bigint "discover_dispute_reversals_cents", default: 0, null: false
t.virtual "discover_net_revenue_cents", type: :bigint, null: false, as: "(((`discover_sales_cents` - `discover_refunds_cents`) - `discover_disputes_cents`) + `discover_dispute_reversals_cents`)", stored: true
t.integer "sales_count", default: 0, null: false
t.integer "full_refunds_count", default: 0, null: false
t.integer "disputes_count", default: 0, null: false
t.integer "dispute_reversals_count", default: 0, null: false
t.virtual "net_sales_count", type: :integer, null: false, as: "(((`sales_count` - `full_refunds_count`) - `disputes_count`) + `dispute_reversals_count`)", stored: true
t.integer "free_sales_count", default: 0, null: false
t.integer "active_nonmemberships_count", default: 0, null: false
t.integer "inactive_nonmemberships_count", default: 0, null: false
t.virtual "net_active_nonmemberships_count", type: :integer, null: false, as: "(`active_nonmemberships_count` - `inactive_nonmemberships_count`)", stored: true
t.integer "active_memberships_count", default: 0, null: false
t.integer "inactive_memberships_count", default: 0, null: false
t.virtual "net_active_memberships_count", type: :integer, null: false, as: "(`active_memberships_count` - `inactive_memberships_count`)", stored: true
t.virtual "net_active_sales_count", type: :integer, null: false, as: "(`net_active_nonmemberships_count` + `net_active_memberships_count`)", stored: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["date"], name: "index_variant_daily_sales_stats_on_date"
t.index ["product_id"], name: "index_variant_daily_sales_stats_on_product_id"
t.index ["seller_id", "date"], name: "index_variant_daily_sales_stats_on_seller_id_and_date"
t.index ["variant_id", "date"], name: "index_variant_daily_sales_stats_on_variant_id_and_date", unique: true
end
create_table "variant_sales_stats", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: true do |t|
t.bigint "seller_id", null: false
t.bigint "product_id", null: false
t.bigint "variant_id", null: false
t.bigint "sales_cents", default: 0, null: false
t.bigint "refunds_cents", default: 0, null: false
t.bigint "disputes_cents", default: 0, null: false
t.bigint "dispute_reversals_cents", default: 0, null: false
t.virtual "net_revenue_cents", type: :bigint, null: false, as: "(((`sales_cents` - `refunds_cents`) - `disputes_cents`) + `dispute_reversals_cents`)", stored: true
t.bigint "fees_cents", default: 0, null: false
t.bigint "fees_refunds_cents", default: 0, null: false
t.bigint "fees_disputes_cents", default: 0, null: false
t.bigint "fees_dispute_reversals_cents", default: 0, null: false
t.virtual "net_fees_cents", type: :bigint, null: false, as: "(((`fees_cents` - `fees_refunds_cents`) - `fees_disputes_cents`) + `fees_dispute_reversals_cents`)", stored: true
t.bigint "affiliate_sales_cents", default: 0, null: false
t.bigint "affiliate_refunds_cents", default: 0, null: false
t.bigint "affiliate_disputes_cents", default: 0, null: false
t.bigint "affiliate_dispute_reversals_cents", default: 0, null: false
t.virtual "net_affiliate_revenue_cents", type: :bigint, null: false, as: "(((`affiliate_sales_cents` - `affiliate_refunds_cents`) - `affiliate_disputes_cents`) + `affiliate_dispute_reversals_cents`)", stored: true
t.virtual "adjusted_net_revenue_cents", type: :bigint, null: false, as: "((`net_revenue_cents` - `net_fees_cents`) - `net_affiliate_revenue_cents`)", stored: true
t.bigint "discover_sales_cents", default: 0, null: false
t.bigint "discover_refunds_cents", default: 0, null: false
t.bigint "discover_disputes_cents", default: 0, null: false
t.bigint "discover_dispute_reversals_cents", default: 0, null: false
t.virtual "discover_net_revenue_cents", type: :bigint, null: false, as: "(((`discover_sales_cents` - `discover_refunds_cents`) - `discover_disputes_cents`) + `discover_dispute_reversals_cents`)", stored: true
t.integer "sales_count", default: 0, null: false
t.integer "full_refunds_count", default: 0, null: false
t.integer "disputes_count", default: 0, null: false
t.integer "dispute_reversals_count", default: 0, null: false
t.virtual "net_sales_count", type: :integer, null: false, as: "(((`sales_count` - `full_refunds_count`) - `disputes_count`) + `dispute_reversals_count`)", stored: true
t.integer "free_sales_count", default: 0, null: false
t.integer "active_nonmemberships_count", default: 0, null: false
t.integer "inactive_nonmemberships_count", default: 0, null: false
t.virtual "net_active_nonmemberships_count", type: :integer, null: false, as: "(`active_nonmemberships_count` - `inactive_nonmemberships_count`)", stored: true
t.integer "active_memberships_count", default: 0, null: false
t.integer "inactive_memberships_count", default: 0, null: false
t.virtual "net_active_memberships_count", type: :integer, null: false, as: "(`active_memberships_count` - `inactive_memberships_count`)", stored: true
t.virtual "net_active_sales_count", type: :integer, null: false, as: "(`net_active_nonmemberships_count` + `net_active_memberships_count`)", stored: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["product_id"], name: "index_variant_sales_stats_on_product_id"
t.index ["seller_id"], name: "index_variant_sales_stats_on_seller_id"
t.index ["variant_id"], name: "index_variant_sales_stats_on_variant_id", unique: true
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20210927134712_add_json_data_to_product_files_archives.rb | db/migrate/20210927134712_add_json_data_to_product_files_archives.rb | # frozen_string_literal: true
class AddJsonDataToProductFilesArchives < ActiveRecord::Migration[6.1]
def change
add_column :product_files_archives, :json_data, :text
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20250925161102_add_paused_to_upsells.rb | db/migrate/20250925161102_add_paused_to_upsells.rb | # frozen_string_literal: true
class AddPausedToUpsells < ActiveRecord::Migration[7.1]
def change
add_column :upsells, :paused, :boolean, default: false, null: false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20150804000000_add_country_to_merchant_accounts.rb | db/migrate/20150804000000_add_country_to_merchant_accounts.rb | # frozen_string_literal: true
class AddCountryToMerchantAccounts < ActiveRecord::Migration
def change
add_column :merchant_accounts, :country, :string, default: "US"
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20180627111725_add_more_indexes_in_purchases.rb | db/migrate/20180627111725_add_more_indexes_in_purchases.rb | # frozen_string_literal: true
class AddMoreIndexesInPurchases < ActiveRecord::Migration
def change
add_index :purchases, :purchase_refund_balance_id
add_index :purchases, :purchase_chargeback_balance_id
add_index :purchases, :purchase_success_balance_id
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20220222192027_add_null_false_to_taxonomies_slug.rb | db/migrate/20220222192027_add_null_false_to_taxonomies_slug.rb | # frozen_string_literal: true
class AddNullFalseToTaxonomiesSlug < ActiveRecord::Migration[6.1]
def up
if Rails.env.development? && Taxonomy.where(slug: nil).exists?
raise <<~ERROR
Your database contains a Taxonomy without slug.
To fix it, run the script to fill the taxonomy slugs
Onetime::FillTaxonomySlugs.process
or re-seed taxonomies in your db
Taxonomy.destroy_all && load 'db/seeds/000_development_staging/taxonomy.rb'
before running this migration.
ERROR
end
change_column_null :taxonomies, :slug, false
change_column_null :taxonomies, :name, true
end
def down
change_column_null :taxonomies, :slug, true
change_column_null :taxonomies, :name, false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120216022958_change_yen_to_jpy.rb | db/migrate/20120216022958_change_yen_to_jpy.rb | # frozen_string_literal: true
class ChangeYenToJpy < ActiveRecord::Migration
def up
User.find_each do |user|
if user.currency_type == "yen"
user.currency_type = "jpy"
end
user.save(validate: false)
end
Link.find_each do |link|
if link.price_currency_type == "yen"
link.price_currency_type = "jpy"
end
link.save(validation: false)
end
Purchase.find_each do |purchase|
if purchase.displayed_price_currency_type == "yen"
purchase.displayed_price_currency_type = "jpy"
end
purchase.save(validation: false)
end
end
def down
User.find_each do |user|
if user.currency_type == "jpy"
user.currency_type = "yen"
end
user.save(validate: false)
end
Link.find_each do |link|
if link.price_currency_type == "jpy"
link.price_currency_type = "yen"
end
link.save(validation: false)
end
Purchase.find_each do |purchase|
if purchase.displayed_price_currency_type == "jpy"
purchase.displayed_price_currency_type = "yen"
end
purchase.save(validation: false)
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20250103191249_add_flags_to_offer_codes.rb | db/migrate/20250103191249_add_flags_to_offer_codes.rb | # frozen_string_literal: true
class AddFlagsToOfferCodes < ActiveRecord::Migration[7.1]
def change
add_column :offer_codes, :flags, :bigint, default: 0, null: false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120211163119_remove_email_required_for_links.rb | db/migrate/20120211163119_remove_email_required_for_links.rb | # frozen_string_literal: true
class RemoveEmailRequiredForLinks < ActiveRecord::Migration
def up
remove_column :links, :email_required
end
def down
add_column :links, :email_required, :boolean, default: 0
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20210922054233_add_flags_to_integrations.rb | db/migrate/20210922054233_add_flags_to_integrations.rb | # frozen_string_literal: true
class AddFlagsToIntegrations < ActiveRecord::Migration[6.1]
def change
add_column :integrations, :flags, :bigint, default: 0, null: false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20231031174049_create_purchase_early_fraud_warnings.rb | db/migrate/20231031174049_create_purchase_early_fraud_warnings.rb | # frozen_string_literal: true
class CreatePurchaseEarlyFraudWarnings < ActiveRecord::Migration[7.0]
def change
create_table :purchase_early_fraud_warnings do |t|
t.bigint :purchase_id, null: false
t.string :processor_id, null: false
t.bigint :dispute_id
t.bigint :refund_id
t.string :fraud_type, null: false
t.boolean :actionable, null: false
t.string :charge_risk_level, null: false
t.datetime :processor_created_at, null: false
t.string :resolution, default: "unknown"
t.datetime :resolved_at
t.timestamps
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20170417140253_add_partial_refunds_to_purchase.rb | db/migrate/20170417140253_add_partial_refunds_to_purchase.rb | # frozen_string_literal: true
class AddPartialRefundsToPurchase < ActiveRecord::Migration
def change
add_column :purchases, :stripe_partially_refunded, :boolean, default: false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20211023222329_add_available_price_cents_to_product_index.rb | db/migrate/20211023222329_add_available_price_cents_to_product_index.rb | # frozen_string_literal: true
class AddAvailablePriceCentsToProductIndex < ActiveRecord::Migration[6.1]
def up
EsClient.indices.put_mapping(
index: Link.index_name,
body: {
properties: {
available_price_cents: { type: "long" },
}
}
)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20150329165612_make_dropbox_url_longer.rb | db/migrate/20150329165612_make_dropbox_url_longer.rb | # frozen_string_literal: true
class MakeDropboxUrlLonger < ActiveRecord::Migration
def change
change_column :dropbox_files, :dropbox_url, :string, limit: 2000
change_column :dropbox_files, :s3_url, :string, limit: 2000
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120430184408_remove_author_from_infos.rb | db/migrate/20120430184408_remove_author_from_infos.rb | # frozen_string_literal: true
class RemoveAuthorFromInfos < ActiveRecord::Migration
def up
remove_column :infos, :author
end
def down
add_column :infos, :author, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120430184136_remove_tags_from_infos.rb | db/migrate/20120430184136_remove_tags_from_infos.rb | # frozen_string_literal: true
class RemoveTagsFromInfos < ActiveRecord::Migration
def up
remove_column :infos, :tags
end
def down
add_column :infos, :tags, :string
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20130304235024_add_default_value_to_webhook_fail_count.rb | db/migrate/20130304235024_add_default_value_to_webhook_fail_count.rb | # frozen_string_literal: true
class AddDefaultValueToWebhookFailCount < ActiveRecord::Migration
def up
change_column :links, :webhook_fail_count, :integer, default: 0
end
def down
change_column :links, :webhook_fail_count, :integer, default: nil
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20130718214055_add_city_rate_to_zip_tax_rates.rb | db/migrate/20130718214055_add_city_rate_to_zip_tax_rates.rb | # frozen_string_literal: true
class AddCityRateToZipTaxRates < ActiveRecord::Migration
def change
rename_column :zip_tax_rates, :special_rate, :city_rate
add_column :zip_tax_rates, :special_rate, :decimal, precision: 8, scale: 7
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20210306103539_reindex_dev_es_records.rb | db/migrate/20210306103539_reindex_dev_es_records.rb | # frozen_string_literal: true
class ReindexDevEsRecords < ActiveRecord::Migration[6.1]
# For developer convenience, we reindex everything since we're now using a new ES server, with no data.
def up
return if Rails.env.production?
if EsClient.info["version"]["number"].starts_with?("6.")
error_message = "=" * 50
error_message += "\n\nYou're running an older docker-compose (with an older ES server), you need to restart it now (e.g. `make local`), and try again.\n\n"
error_message += "=" * 50
raise error_message
end
DevTools.delete_all_indices_and_reindex_all
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20140707165730_add_charge_processor_id_to_credit_card.rb | db/migrate/20140707165730_add_charge_processor_id_to_credit_card.rb | # frozen_string_literal: true
class AddChargeProcessorIdToCreditCard < ActiveRecord::Migration
def up
add_column :credit_cards, :charge_processor_id, :string
CreditCard.update_all({ charge_processor_id: "stripe" })
end
def down
remove_column :credit_cards, :charge_processor_id
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20220429193757_add_discover_fee_to_recommended_purchase_infos.rb | db/migrate/20220429193757_add_discover_fee_to_recommended_purchase_infos.rb | # frozen_string_literal: true
class AddDiscoverFeeToRecommendedPurchaseInfos < ActiveRecord::Migration[6.1]
def change
add_column :recommended_purchase_infos, :discover_fee_per_thousand, :integer
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20210625121544_change_links_name_null.rb | db/migrate/20210625121544_change_links_name_null.rb | # frozen_string_literal: true
class ChangeLinksNameNull < ActiveRecord::Migration[6.1]
def change
change_column_null :links, :name, false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20240819015410_make_subtitle_files_cdn_deletable.rb | db/migrate/20240819015410_make_subtitle_files_cdn_deletable.rb | # frozen_string_literal: true
class MakeSubtitleFilesCdnDeletable < ActiveRecord::Migration[7.1]
def up
change_table :subtitle_files, bulk: true do |t|
t.datetime :deleted_from_cdn_at
t.index :url
t.index :deleted_at
t.change :id, :bigint, null: false, auto_increment: true
t.change :product_file_id, :bigint
t.change :deleted_at, :datetime, limit: 6
t.change :created_at, :datetime, limit: 6
t.change :updated_at, :datetime, limit: 6
end
end
def down
change_table :subtitle_files, bulk: true do |t|
t.remove :deleted_from_cdn_at
t.remove_index :url
t.remove_index :deleted_at
t.change :id, :int, null: false, auto_increment: true
t.change :product_file_id, :int
t.change :deleted_at, :datetime, precision: nil
t.change :created_at, :datetime, precision: nil
t.change :updated_at, :datetime, precision: nil
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120425190921_change_type_back_to_card_type.rb | db/migrate/20120425190921_change_type_back_to_card_type.rb | # frozen_string_literal: true
class ChangeTypeBackToCardType < ActiveRecord::Migration
def up
rename_column :credit_cards, :type, :card_type
end
def down
rename_column :credit_cards, :card_type, :type
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20130904230941_prepare_bank_account.rb | db/migrate/20130904230941_prepare_bank_account.rb | # frozen_string_literal: true
class PrepareBankAccount < ActiveRecord::Migration
def up
rename_table :ach_accounts, :bank_accounts
add_column :bank_accounts, :type, :string, default: "AchAccount"
add_column :bank_accounts, :branch_code, :string
rename_column :bank_accounts, :routing_number, :bank_number
rename_column :payments, :ach_account_id, :bank_account_id
add_column :payments, :amount_cents_in_local_currency, :integer
end
def down
rename_table :bank_accounts, :ach_accounts
remove_column :ach_accounst, :type
remove_column :ach_accounst, :branch_code
rename_column :ach_accounts, :bank_number, :routing_number
rename_column :payments, :bank_account_id, :ach_account_id
remove_column :payments, :amount_cents_in_local_currency
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120226234156_change_type_to_filetype.rb | db/migrate/20120226234156_change_type_to_filetype.rb | # frozen_string_literal: true
class ChangeTypeToFiletype < ActiveRecord::Migration
def up
remove_column :infos, :type
add_column :infos, :filetype, :string
end
def down
remove_column :infos, :filetype
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20210621081510_add_content_updated_at_to_product_index.rb | db/migrate/20210621081510_add_content_updated_at_to_product_index.rb | # frozen_string_literal: true
class AddContentUpdatedAtToProductIndex < ActiveRecord::Migration[6.1]
def up
EsClient.indices.put_mapping(
index: Link.index_name,
body: {
properties: {
content_updated_at: { type: "date" },
}
}
)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20130209224715_add_parent_id_to_purchases.rb | db/migrate/20130209224715_add_parent_id_to_purchases.rb | # frozen_string_literal: true
class AddParentIdToPurchases < ActiveRecord::Migration
def change
add_column :purchases, :parent_id, :integer
add_column :purchases, :flags, :integer, default: 0, null: false
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20210502153119_remove_oauth_fields.rb | db/migrate/20210502153119_remove_oauth_fields.rb | # frozen_string_literal: true
class RemoveOauthFields < ActiveRecord::Migration[6.1]
def up
change_table :oauth_applications do |t|
t.remove :icon_file_name
t.remove :icon_content_type
t.remove :icon_file_size
t.remove :icon_updated_at
t.remove :icon_guid
end
end
def down
change_table :oauth_applications do |t|
t.string :icon_file_name
t.string :icon_content_type
t.integer :icon_file_size
t.datetime :icon_updated_at
t.string :icon_guid
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20130409211227_add_index_to_link_id_on_subscriptions.rb | db/migrate/20130409211227_add_index_to_link_id_on_subscriptions.rb | # frozen_string_literal: true
class AddIndexToLinkIdOnSubscriptions < ActiveRecord::Migration
def change
add_index :subscriptions, :link_id
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20210620233525_remove_foreign_key_constraints.rb | db/migrate/20210620233525_remove_foreign_key_constraints.rb | # frozen_string_literal: true
class RemoveForeignKeyConstraints < ActiveRecord::Migration[6.1]
def up
remove_foreign_key :devices, :users
remove_foreign_key :featured_posts, :installments, column: :post_id
remove_foreign_key :installment_events, :installments
remove_foreign_key :large_sellers, :users
remove_foreign_key :product_files_archives, :base_variants, column: :variant_id
remove_foreign_key :product_reviews, :purchases
remove_foreign_key :profile_tags, :tags
remove_foreign_key :profile_tags, :users
remove_foreign_key :thumbnails, :links
end
def down
add_foreign_key "devices", "users", name: "_fk_rails_410b63ef65", on_delete: :cascade
add_foreign_key "featured_posts", "installments", column: "post_id"
add_foreign_key "installment_events", "installments", name: "_fk_rails_10f1699f91", on_delete: :cascade
add_foreign_key "large_sellers", "users", name: "_fk_rails_a0fca89024", on_delete: :cascade
add_foreign_key "product_files_archives", "base_variants", column: "variant_id", name: "_fk_rails_c054ae328a", on_delete: :cascade
add_foreign_key "product_reviews", "purchases", name: "_fk_rails_3ec4cdfc41", on_delete: :cascade
add_foreign_key "profile_tags", "tags", name: "_fk_rails_1c81d1ddab", on_delete: :cascade
add_foreign_key "profile_tags", "users", name: "_fk_rails_657484ee2a", on_delete: :cascade
add_foreign_key "thumbnails", "links", column: "product_id", name: "_fk_rails_f507e14b0c"
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20120928012423_add_index_to_created_at_in_purchases.rb | db/migrate/20120928012423_add_index_to_created_at_in_purchases.rb | # frozen_string_literal: true
class AddIndexToCreatedAtInPurchases < ActiveRecord::Migration
def change
add_index :purchases, :created_at
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20250328062708_create_collaborator_invitations.rb | db/migrate/20250328062708_create_collaborator_invitations.rb | # frozen_string_literal: true
class CreateCollaboratorInvitations < ActiveRecord::Migration[7.1]
def change
create_table :collaborator_invitations do |t|
t.belongs_to :collaborator, null: false, foreign_key: false, index: { unique: true }
t.timestamps
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20241014141423_add_index_on_transcoded_videos_original_video_key.rb | db/migrate/20241014141423_add_index_on_transcoded_videos_original_video_key.rb | # frozen_string_literal: true
class AddIndexOnTranscodedVideosOriginalVideoKey < ActiveRecord::Migration[7.1]
def change
add_index :transcoded_videos, :original_video_key
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20150128193618_add_tax_fields_to_refunds.rb | db/migrate/20150128193618_add_tax_fields_to_refunds.rb | # frozen_string_literal: true
class AddTaxFieldsToRefunds < ActiveRecord::Migration
def change
add_column :refunds, :creator_tax_cents, :integer
add_column :refunds, :gumroad_tax_cents, :integer
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20130228225328_add_deleted_at_to_installments.rb | db/migrate/20130228225328_add_deleted_at_to_installments.rb | # frozen_string_literal: true
class AddDeletedAtToInstallments < ActiveRecord::Migration
def change
add_column :installments, :deleted_at, :datetime
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20230510160658_create_audience_members.rb | db/migrate/20230510160658_create_audience_members.rb | # frozen_string_literal: true
class CreateAudienceMembers < ActiveRecord::Migration[7.0]
def change
create_table :audience_members do |t|
t.bigint :seller_id, null: false
t.string :email, null: false
t.json :details
t.timestamps
t.index [:seller_id, :email], unique: true
# derived columns and their indexes, used for performance reasons
t.boolean :customer, default: false, null: false
t.boolean :follower, default: false, null: false
t.boolean :affiliate, default: false, null: false
t.integer :min_paid_cents
t.integer :max_paid_cents
t.datetime :min_created_at, precision: nil
t.datetime :max_created_at, precision: nil
t.datetime :min_purchase_created_at, precision: nil
t.datetime :max_purchase_created_at, precision: nil
t.datetime :follower_created_at, precision: nil
t.datetime :min_affiliate_created_at, precision: nil
t.datetime :max_affiliate_created_at, precision: nil
t.index "seller_id, (cast(json_extract(`details`, '$.purchases[*].product_id') as unsigned array))", name: "idx_audience_on_seller_and_purchases_products_ids"
t.index "seller_id, (cast(json_extract(`details`, '$.purchases[*].variant_id') as unsigned array))", name: "idx_audience_on_seller_and_purchases_variants_ids"
t.index "seller_id, (cast(json_extract(`details`, '$.purchases[*].country') as char(100) array))", name: "idx_audience_on_seller_and_purchases_countries"
t.index [:seller_id, :customer, :follower, :affiliate], name: "idx_audience_on_seller_and_types"
t.index [:seller_id, :min_paid_cents, :max_paid_cents], name: "idx_audience_on_seller_and_minmax_paid_cents"
t.index [:seller_id, :min_created_at, :max_created_at], name: "idx_audience_on_seller_and_minmax_created_at"
t.index [:seller_id, :min_purchase_created_at, :max_purchase_created_at], name: "idx_audience_on_seller_and_minmax_purchase_created_at"
t.index [:seller_id, :follower_created_at], name: "idx_audience_on_seller_and_follower_created_at"
t.index [:seller_id, :min_affiliate_created_at, :max_affiliate_created_at], name: "idx_audience_on_seller_and_minmax_affiliate_created_at"
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20201203030128_set_dropbox_files_to_utf8mb4.rb | db/migrate/20201203030128_set_dropbox_files_to_utf8mb4.rb | # frozen_string_literal: true
class SetDropboxFilesToUtf8mb4 < ActiveRecord::Migration[6.0]
def up
execute alter_query("utf8mb4")
end
def down
execute alter_query("utf8")
end
private
def alter_query(charset)
"ALTER TABLE dropbox_files" \
" CHARACTER SET #{charset} COLLATE #{charset}_unicode_ci," \
" MODIFY `state` VARCHAR(255) CHARACTER SET #{charset} COLLATE #{charset}_unicode_ci," \
" MODIFY `dropbox_url` VARCHAR(2000) CHARACTER SET #{charset} COLLATE #{charset}_unicode_ci," \
" MODIFY `json_data` MEDIUMTEXT CHARACTER SET #{charset} COLLATE #{charset}_unicode_ci," \
" MODIFY `s3_url` VARCHAR(2000) CHARACTER SET #{charset} COLLATE #{charset}_unicode_ci"
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/db/migrate/20240804195838_add_description_to_wishlists.rb | db/migrate/20240804195838_add_description_to_wishlists.rb | # frozen_string_literal: true
class AddDescriptionToWishlists < ActiveRecord::Migration[7.1]
def change
add_column :wishlists, :description, :text
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.