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 | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240303021205_rename_version_tables.rb | Ruby | mit | 84 | main | 519 | class RenameVersionTables < ActiveRecord::Migration[7.1]
def change
rename_table("glossary_terms_versions", "glossary_term_versions")
rename_table("locations_versions", "location_versions")
rename_table("location_descriptions_versions",
"location_description_versions")
rename_table("n... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20110206214103_house_cleaning.rb | Ruby | mit | 84 | main | 905 | # encoding: utf-8
class HouseCleaning < ActiveRecord::Migration
def self.up
drop_table :add_image_test_logs
drop_table :t1
drop_table :t2
end
def self.down
create_table "t2", id: false, force: true do |t|
t.integer "j"
t.integer "k"
end
create_table "t1", id: false, force: tr... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100324010000_clean_rss_logs.rb | Ruby | mit | 84 | main | 7,884 | # encoding: utf-8
class CleanRssLogs < ActiveRecord::Migration
def self.up
cutoff = 1.year.ago
i = 0
num = RssLog.count
old_pct = nil
for log in RssLog.all
i += 1
pct = 100 * i / num
if pct != old_pct
$stdout.print "#{pct}%\r"
$stdout.flush
end
old_pc... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100201000000_descriptions.rb | Ruby | mit | 84 | main | 30,603 | # encoding: utf-8
class Descriptions < ActiveRecord::Migration
def self.up
# ------------------------------------
# Add "meta" flag to user_groups.
# ------------------------------------
add_column :user_groups, :meta, :boolean, default: false
# ----------------------------
# Add some new ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20250403174427_add_base_url_to_external_sites.rb | Ruby | mit | 84 | main | 313 | class AddBaseURLToExternalSites < ActiveRecord::Migration[7.2]
def up
add_column :external_sites, :base_url, :string, null: false
ExternalSite.find(1).update(
base_url: "https://www.mycoportal.org/portal/collections/"
)
end
def down
remove_column :external_sites, :base_url
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20130319120600_tweak_keep_original_image_filenames_prefs.rb | Ruby | mit | 84 | main | 795 | class TweakKeepOriginalImageFilenamesPrefs < ActiveRecord::Migration
def self.up
rename_column(:users, :keep_filenames, :old_keep_filenames)
add_column(:users, :keep_filenames, :enum, default: :keep_and_show, null: false, limit: [:toss, :keep_but_hide, :keep_and_show])
User.connection.update %(
UPDA... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240126063829_add_target_index_to_comments.rb | Ruby | mit | 84 | main | 248 | class AddTargetIndexToComments < ActiveRecord::Migration[7.1]
def up
add_index :comments, [:target_id, :target_type], name: :target_index
end
def down
remove_index :comments, [:target_id, :target_type], name: :target_index
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20101208030838_anonymous_donations.rb | Ruby | mit | 84 | main | 434 | # encoding: utf-8
class AnonymousDonations < ActiveRecord::Migration
def self.up
add_column :donations, :anonymous, :boolean, default: false, null: false
add_column :donations, :reviewed, :boolean, default: true, null: false
add_column :donations, :user_id, :integer
end
def self.down
remove_colum... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120404175200_deanonymize_image_votes.rb | Ruby | mit | 84 | main | 927 | class DeanonymizeImageVotes < ActiveRecord::Migration
def self.up
values = []
for image_id, votes in Image.connection.select_rows %(
SELECT id, votes FROM images WHERE votes IS NOT null AND votes != ""
)
hash = Hash[*votes.split(" ")]
for user_id, value in hash
values << [ima... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20190722171000_remove_index_from_images_observations.rb | Ruby | mit | 84 | main | 215 | class RemoveIndexFromImagesObservations < ActiveRecord::Migration[4.2]
def up
remove_index :images_observations, :observation_id
end
def down
add_index :images_observations, :observation_id
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20140901161745_text_limit_cleanup.rb | Ruby | mit | 84 | main | 271 | class TextLimitCleanup < ActiveRecord::Migration
def up
change_column(:herbaria, :mailing_address, :text, limit: nil)
change_column(:herbaria, :description, :text, limit: nil)
change_column(:specimens, :notes, :text, limit: nil)
end
def down
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240415115711_user_stats_no_default_timestamp.rb | Ruby | mit | 84 | main | 202 | class UserStatsNoDefaultTimestamp < ActiveRecord::Migration[7.1]
def change
change_column_default(:user_stats, :created_at, nil)
change_column_default(:user_stats, :updated_at, nil)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260317014446_add_missing_indexes.rb | Ruby | mit | 84 | main | 348 | class AddMissingIndexes < ActiveRecord::Migration[7.2]
def change
add_index(:project_observations, :project_id, if_not_exists: true)
add_index(:project_observations, :observation_id, if_not_exists: true)
add_index(:observations, :name_id, if_not_exists: true)
add_index(:observations, :location_id, if_... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260320123207_move_field_slip_from_observations_to_occurrences.rb | Ruby | mit | 84 | main | 2,415 | # frozen_string_literal: true
# Move field_slip_id from observations to occurrences.
# For each observation with a field_slip_id:
# - If it already has an occurrence, set that occurrence's field_slip_id
# - If not, create a single-observation occurrence and set field_slip_id
class MoveFieldSlipFromObservationsToOc... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20130301051051_add_public_domain.rb | Ruby | mit | 84 | main | 360 | class AddPublicDomain < ActiveRecord::Migration
def self.up
pd = License.new
pd.display_name = "Public Domain"
pd.url = "http://wiki.creativecommons.org/Public_domain/"
pd.form_name = "publicdomain"
pd.deprecated = false
pd.save
end
def self.down
pd = License.find_by_form_name("public... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220928163200_add_blocked_to_users.rb | Ruby | mit | 84 | main | 340 | # frozen_string_literal: true
class AddBlockedToUsers < ActiveRecord::Migration[6.1]
def change
add_column(:users, :blocked, :boolean, default: false, null: false)
block_byrain!
end
# We used to have this hard-coded in application_controller.
def block_byrain!
User.where(id: 2750).update_all(block... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260322000000_add_own_observations_to_inat_imports.rb | Ruby | mit | 84 | main | 225 | # frozen_string_literal: true
class AddOwnObservationsToInatImports < ActiveRecord::Migration[7.2]
def change
add_column(:inat_imports, :own_observations, :boolean,
default: true, null: false)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220614002914_add_primary_key_to_observations_species_lists.rb | Ruby | mit | 84 | main | 238 | class AddPrimaryKeyToObservationsSpeciesLists < ActiveRecord::Migration[6.1]
def change
rename_table("observations_species_lists", "species_list_observations")
add_column(:species_list_observations, :id, :primary_key)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20221215233523_rename_notifications_to_name_trackers.rb | Ruby | mit | 84 | main | 494 | class RenameNotificationsToNameTrackers < ActiveRecord::Migration[6.1]
def self.up
rename_table :notifications, :name_trackers
NameTracker.find_each do |n_t|
Interest.create!({
target_type: "NameTracker",
target_id: n_t.id,
user_id: n_t.user_id,
state: 1,
updated_... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120712135300_fix_name_ordering_again.rb | Ruby | mit | 84 | main | 945 | # encoding: utf-8
class FixNameOrderingAgain < ActiveRecord::Migration
def self.up
redo_sort_names
end
def self.down
end
def self.redo_sort_names
data = []
for id, rank, text_name, author, sort_name in Name.connection.select_rows %(
SELECT id, rank, text_name, author, sort_name FROM names... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120605005200_clean_names.rb | Ruby | mit | 84 | main | 222 | class CleanNames < ActiveRecord::Migration
def self.up
change_column(:names, :rank, :enum, limit: Name.all_ranks)
change_column(:names, :author, :string, limit: 100, null: false)
end
def self.down
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220614070009_add_primary_key_to_description_user_join_tables.rb | Ruby | mit | 84 | main | 1,574 | class AddPrimaryKeyToDescriptionUserJoinTables < ActiveRecord::Migration[6.1]
def change
rename_table(
"location_descriptions_admins", "location_description_admins"
)
add_column(:location_description_admins, :id, :primary_key)
rename_table(
"location_descriptions_authors", "location_descr... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120626163100_fix_natural_varieties.rb | Ruby | mit | 84 | main | 772 | # encoding: utf-8
class FixNaturalVarieties < ActiveRecord::Migration
def self.up
for id, text_name in Name.connection.select_rows %(
SELECT id, text_name FROM names
WHERE rank in ('Subspecies', 'Variety', 'Form')
AND COALESCE(author, '') != ''
)
words = text_name.split(" ")
i... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20141230043405_change_enum_columns_to_integers.rb | Ruby | mit | 84 | main | 1,923 | class ChangeEnumColumnsToIntegers < ActiveRecord::Migration
def up
change_column :location_descriptions, :source_type, :integer
change_column :name_descriptions, :review_status, :integer, default: 0
change_column :name_descriptions, :source_type, :integer
change_column :names, :rank, :integer
chan... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260424170000_add_gps_dubious_to_observations.rb | Ruby | mit | 84 | main | 663 | # frozen_string_literal: true
# Cached flag: true when `Observation#lat` / `lng` is geographically
# far (>50 km) from its `location`'s bounding box. GPS-based search
# scopes (`gps_in_box`, `gps_in_box_over_dateline`) exclude dubious
# rows so obs whose GPS contradicts an explicit label don't leak into
# location-fil... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260426000002_remove_classification_from_observations.rb | Ruby | mit | 84 | main | 527 | # frozen_string_literal: true
# Drop the `observations.classification` denormalized cache. Clade
# membership now reads from `names.classification` (a smaller column,
# scanned ~5-9× faster — see discussion #4163). The column had one
# reader (`Observation#one_clade`) and a fan-out cache callback
# (`Name#update_obser... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220614184435_change_translation_string_tags_for_description_authors_and_editors.rb | Ruby | mit | 84 | main | 1,077 | class ChangeTranslationStringTagsForDescriptionAuthorsAndEditors < ActiveRecord::Migration[6.1]
TAG_PAIRS = [
%w[
user_stats_location_descriptions_authors
user_stats_location_description_authors
],
%w[
user_stats_location_descriptions_editors
user_stats_location_description_edi... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240518181000_rename_inat_import_columns.rb | Ruby | mit | 84 | main | 216 | class RenameInatImportColumns < ActiveRecord::Migration[7.2]
def change
rename_column :inat_imports, :total_imports, :total_imported_count
rename_column :inat_imports, :total_time, :total_seconds
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220614003606_add_primary_key_to_herbarium_records_observations.rb | Ruby | mit | 84 | main | 266 | class AddPrimaryKeyToHerbariumRecordsObservations < ActiveRecord::Migration[6.1]
def change
rename_table(
"herbarium_records_observations", "observation_herbarium_records"
)
add_column(:observation_herbarium_records, :id, :primary_key)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20221001155200_create_ml_models.rb | Ruby | mit | 84 | main | 601 | # frozen_string_literal: true
class CreateMlModels < ActiveRecord::Migration[6.1]
def change
create_table(:visual_models) do |t|
t.string(:name, null: false)
t.timestamps
end
create_table(:visual_groups) do |t|
t.integer(:visual_model_id)
t.string(:name, null: false)
t.boo... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120413175000_association_of_projects_and_observations_images_and_species_lists.rb | Ruby | mit | 84 | main | 730 | class AssociationOfProjectsAndObservationsImagesAndSpeciesLists < ActiveRecord::Migration
def self.up
create_table :images_projects do |t|
t.column "image_id", :integer, null: false
t.column "project_id", :integer, null: false
end
create_table :observations_projects do |t|
t.column "ob... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220614003223_add_primary_key_to_user_groups_users.rb | Ruby | mit | 84 | main | 202 | class AddPrimaryKeyToUserGroupsUsers < ActiveRecord::Migration[6.1]
def change
rename_table("user_groups_users", "user_group_users")
add_column(:user_group_users, :id, :primary_key)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120527000000_convert_your_database.rb | Ruby | mit | 84 | main | 511 | class ConvertYourDatabase < ActiveRecord::Migration
def self.up
puts %(
************** You must convert your database! **************
1. cc -o convert_old_database script/convert_old_database.c
2. mysqldump -u mo -p mo_development > database.old
3. cat database.old | ./convert_old_databa... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20250223095614_filter_translation_strings_with_to_has.rb | Ruby | mit | 84 | main | 1,903 | class FilterTranslationStringsWithToHas < ActiveRecord::Migration[7.2]
def up
TranslationString.rename_tags({
prefs_filters_with_images: :prefs_filters_has_images,
prefs_filters_with_specimen: :prefs_filters_has_specimen,
advanced_search_filter_with_images:
:advanced_search_filter_has_imag... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171120145900_create_collection_numbers.rb | Ruby | mit | 84 | main | 577 | class CreateCollectionNumbers < ActiveRecord::Migration
def up
create_table :collection_numbers, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.timestamps
t.integer :user_id
t.string :name
t.string :number
end
create_table :collection_numbers_observations, options: "E... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220614003047_add_primary_key_to_projects_species_lists.rb | Ruby | mit | 84 | main | 222 | class AddPrimaryKeyToProjectsSpeciesLists < ActiveRecord::Migration[6.1]
def change
rename_table("projects_species_lists", "project_species_lists")
add_column(:project_species_lists, :id, :primary_key)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100324020000_convert_database_to_utc.rb | Ruby | mit | 84 | main | 2,062 | # encoding: utf-8
class ConvertDatabaseToUtc < ActiveRecord::Migration
def self.up
correct_datetimes("+")
end
def self.down
correct_datetimes("-")
end
def self.correct_datetimes(sign)
for table, cols in [
["comments", %w(created modified)],
["images", %w(created modified last_view)],... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20251215233038_update_nil_response_errors_in_inat_imports.rb | Ruby | mit | 84 | main | 636 | # frozen_string_literal: true
# Update existing records with nil response_errors to empty string
# This is a data-only migration that doesn't attempt to set a database default,
# since MySQL doesn't allow defaults on TEXT columns.
# The InatImport model's after_initialize callback ensures new instances
# have response... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120522131900_mo_api_keys.rb | Ruby | mit | 84 | main | 471 | class MoApiKeys < ActiveRecord::Migration
def self.up
create_table :mo_api_keys, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: true do |t|
t.column :created, :datetime
t.column :last_used, :datetime
t.column :num_uses, :integer, default: 0
t.column :user_id, :integer, null: false
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120521132200_add_hide_authors_preference.rb | Ruby | mit | 84 | main | 249 | class AddHideAuthorsPreference < ActiveRecord::Migration
def self.up
add_column :users, :hide_authors, :enum, default: :none, null: false, limit: [:none, :above_species]
end
def self.down
remove_column :users, :hide_authors
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20210301122443_create_contest_votes.rb | Ruby | mit | 84 | main | 353 | # frozen_string_literal: true
class CreateContestVotes < ActiveRecord::Migration[5.2]
def change
create_table(:contest_votes,
options: "ENGINE=InnoDB DEFAULT CHARSET=utf8") do |t|
t.integer(:contest_entry_id)
t.integer(:user_id)
t.integer(:vote)
t.boolean(:confirmed)
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20170513222059_create_sequences.rb | Ruby | mit | 84 | main | 313 | class CreateSequences < ActiveRecord::Migration
def change
create_table :sequences do |t|
t.integer :observation_id
t.integer :user_id
t.text :locus
t.text :bases
t.string :archive
t.string :accession
t.text :notes
t.timestamps null: false
end
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120527125200_database_translations.rb | Ruby | mit | 84 | main | 4,871 | # encoding: utf-8
require "yaml"
class DatabaseTranslations < ActiveRecord::Migration
def self.up
begin
drop_table :languages
drop_table :translation_strings
drop_table :translation_strings_versions
rescue
end
create_table :languages, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8",... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260416192916_create_project_excluded_observations.rb | Ruby | mit | 84 | main | 734 | # frozen_string_literal: true
class CreateProjectExcludedObservations < ActiveRecord::Migration[7.2]
def change
create_table(:project_excluded_observations) do |t|
t.integer(:observation_id, null: false)
t.integer(:project_id, null: false)
end
add_index(:project_excluded_observations, :obser... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120701173300_add_auth_code_to_users.rb | Ruby | mit | 84 | main | 747 | # encoding: utf-8
require "user"
class User
def self.get_old_auth_code(password)
old_auth_code(password)
end
end
class AddAuthCodeToUsers < ActiveRecord::Migration
def self.up
begin
add_column(:users, :auth_code, :string, limit: 40)
rescue
nil
end
fill_in_auth_codes
end
def ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20190722150500_add_index_to_images_observations.rb | Ruby | mit | 84 | main | 210 | class AddIndexToImagesObservations < ActiveRecord::Migration[4.2]
def up
add_index :images_observations, :observation_id
end
def down
remove_index :images_observations, :observation_id
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20230430044838_add_column_to_observations_log_updated_at.rb | Ruby | mit | 84 | main | 297 | class AddColumnToObservationsLogUpdatedAt < ActiveRecord::Migration[6.1]
def up
add_column(:observations, :log_updated_at, :datetime)
Observation.joins(:rss_log).update_all(log_updated_at: RssLog[:updated_at])
end
def down
remove_column(:observations, :log_updated_at)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100412000000_add_ok_for_export_to_names.rb | Ruby | mit | 84 | main | 992 | # encoding: utf-8
class AddOkForExportToNames < ActiveRecord::Migration
def self.up
add_column :names, :ok_for_export, :boolean, null: false, default: true
add_column :locations, :ok_for_export, :boolean, null: false, default: true
add_column :location_descriptions, :ok_for_export, :boolean, null: false, ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240309072017_create_user_stats.rb | Ruby | mit | 84 | main | 1,454 | class CreateUserStats < ActiveRecord::Migration[7.1]
def up
create_table :user_stats do |t|
t.integer(:user_id, default: 0, null: false)
t.integer(:comments, default: 0, null: false)
t.integer(:images, default: 0, null: false)
t.integer(:location_description_authors, default: 0, null: fal... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20121129170716_update_specimens_and_herbaria.rb | Ruby | mit | 84 | main | 461 | class UpdateSpecimensAndHerbaria < ActiveRecord::Migration
def self.up
add_column(:specimens, :user_id, :integer, null: false)
add_column(:specimens, :herbarium_label, :string, limit: 80, default: "", null: false)
remove_column :specimens, :label
end
def self.down
add_column(:specimens, :label, :... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171218100900_propagate_generic_classifications.rb | Ruby | mit | 84 | main | 2,643 | class PropagateGenericClassifications < ActiveRecord::Migration
def up
puts "Refresh classification for genera from descriptions..."
Name.connection.execute(%(
UPDATE names n, name_descriptions nd
SET n.classification = nd.classification
WHERE nd.id = n.description_id
AND n.rank = #{... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240713224450_create_inat_imports.rb | Ruby | mit | 84 | main | 217 | class CreateInatImports < ActiveRecord::Migration[7.1]
def change
create_table :inat_imports do |t|
t.integer :user_id
t.integer :state
t.string :inat_ids
t.timestamps
end
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100325010000_image_votes.rb | Ruby | mit | 84 | main | 800 | # encoding: utf-8
class ImageVotes < ActiveRecord::Migration
def self.up
add_column :images, :votes, :text
add_column :images, :vote_cache, :float
Image.connection.update %(
UPDATE images
SET votes = CONCAT(reviewer_id, " ", IF(quality = "low", 1, IF(quality = "medium", 2, 3))),
vote... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20130908210507_separate_term_thumb_from_images.rb | Ruby | mit | 84 | main | 660 | class SeparateTermThumbFromImages < ActiveRecord::Migration
def self.up
Term.record_timestamps = false
# for term in Term.find(:all) # Rails 3
for term in Term.all
if term.images.member?(term.thumb_image)
term.images.delete(term.thumb_image)
term.save_without_our_callbacks
end
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20130804114305_create_terms.rb | Ruby | mit | 84 | main | 260 | class CreateTerms < ActiveRecord::Migration
def self.up
create_table :terms do |t|
t.string "name", limit: 1024
t.text "description"
t.integer "image_id"
t.timestamps
end
end
def self.down
drop_table :terms
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220614002507_add_primary_key_to_observations_projects.rb | Ruby | mit | 84 | main | 219 | class AddPrimaryKeyToObservationsProjects < ActiveRecord::Migration[6.1]
def change
rename_table("observations_projects", "project_observations")
add_column(:project_observations, :id, :primary_key)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120609230300_out_with_observation_name_in_with_sort_name_long_live_sort_name.rb | Ruby | mit | 84 | main | 561 | # encoding: utf-8
class OutWithObservationNameInWithSortNameLongLiveSortName < ActiveRecord::Migration
def self.up
rename_column(:names, :observation_name, :sort_name)
rename_column(:names_versions, :observation_name, :sort_name)
Name.connection.update %(
UPDATE names SET sort_name = REPLACE(TRIM(L... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20140328194655_strip_region_codes.rb | Ruby | mit | 84 | main | 372 | class StripRegionCodes < ActiveRecord::Migration
def self.up
add_column :languages, :region, :string, limit: 4
for l in Language.all
l.locale, l.region = l.locale.split("-")
l.save
end
end
def self.down
for l in Language.all
l.locale = "#{l.locale}-#{l.region}"
l.save
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20241117211300_create_original_image_requests_table.rb | Ruby | mit | 84 | main | 254 | # frozen_string_literal: true
class CreateOriginalImageRequestsTable < ActiveRecord::Migration[7.1]
def change
create_table(:original_image_requests) do |t|
t.integer(:user_id)
t.integer(:image_id)
t.timestamps
end
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20121215143150_herbarium_code.rb | Ruby | mit | 84 | main | 206 | class HerbariumCode < ActiveRecord::Migration
def self.up
add_column(:herbaria, :code, :string, limit: 8, default: "", null: false)
end
def self.down
remove_column :herbaria, :code
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100324000000_default_rss_type.rb | Ruby | mit | 84 | main | 468 | # encoding: utf-8
class DefaultRssType < ActiveRecord::Migration
def self.up
# Give user the ability to choose which RSS log type(s) they want to see by
# default. We will need to make this longer if we add more types, as 40
# characters is just enough for "location name observation species_list".
ad... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260407193046_create_project_target_locations.rb | Ruby | mit | 84 | main | 472 | # frozen_string_literal: true
class CreateProjectTargetLocations < ActiveRecord::Migration[7.2]
def change
create_table(:project_target_locations) do |t|
t.integer(:project_id, null: false)
t.integer(:location_id, null: false)
end
add_index(:project_target_locations, :project_id)
add_ind... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120516135000_fix_project_association_tables.rb | Ruby | mit | 84 | main | 772 | class FixProjectAssociationTables < ActiveRecord::Migration
def self.up
drop_table :images_projects
drop_table :observations_projects
drop_table :projects_species_lists
create_table :images_projects, id: false, force: true do |t|
t.column "image_id", :integer, null: false
t.column "proje... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100325000000_remove_email_digest.rb | Ruby | mit | 84 | main | 201 | # encoding: utf-8
class RemoveEmailDigest < ActiveRecord::Migration
def self.up
remove_column :users, :email_digest
end
def self.down
add_column :users, :email_digest, :string
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171214133000_add_locks_to_names_and_locations.rb | Ruby | mit | 84 | main | 1,232 | class AddLocksToNamesAndLocations < ActiveRecord::Migration
def up
add_column :names, :locked, :boolean, default: false, null: false
add_column :locations, :locked, :boolean, default: false, null: false
# Lock "Fungi".
Name.unknown.update_attributes(locked: true)
# Lock "Earth".
Location.unk... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20250512174607_solid_cable_to_main_db.rb | Ruby | mit | 84 | main | 762 | # frozen_string_literal: true
class SolidCableToMainDb < ActiveRecord::Migration[7.2]
def change
create_table("solid_cable_messages", charset: "utf8mb4",
collation: "utf8mb4_0900_ai_ci",
force: :cascade) do |t|
t.binary("chan... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240420135421_add_title_to_field_slip_job_trackers.rb | Ruby | mit | 84 | main | 233 | # frozen_string_literal: true
class AddTitleToFieldSlipJobTrackers < ActiveRecord::Migration[7.1]
def change
add_column(:field_slip_job_trackers, :title, :string,
limit: 100, default: "", null: false)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20170713204001_change_observation_notes_to_yaml.rb | Ruby | mit | 84 | main | 3,013 | class ChangeObservationNotesToYaml < ActiveRecord::Migration
# ***** THIS MIGRATION MUST BE RUN WITH Observation::serialize :notes ********
# migrate notes to a YAML serialized hash, any notes converted to the
# value of the serialized "Other:" key
# If notes nil or not present, then convert them to a serializ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20101130031436_create_donations.rb | Ruby | mit | 84 | main | 406 | # encoding: utf-8
class CreateDonations < ActiveRecord::Migration
def self.up
create_table :donations, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: true do |t|
t.column "amount", :decimal, precision: 12, scale: 2
t.column "who", :string, limit: 100
t.column "email", :string, limit: 100
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240518180000_add_total_imports_and_total_time_to_inat_imports.rb | Ruby | mit | 84 | main | 208 | class AddTotalImportsAndTotalTimeToInatImports < ActiveRecord::Migration[7.2]
def change
add_column :inat_imports, :total_imports, :integer
add_column :inat_imports, :total_time, :integer
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120421105106_add_registration_count.rb | Ruby | mit | 84 | main | 217 | class AddRegistrationCount < ActiveRecord::Migration
def self.up
add_column :conference_registrations, :how_many, :integer
end
def self.down
remove_column :conference_registrations, :how_many
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240126233636_redo_indexes_for_observation_views.rb | Ruby | mit | 84 | main | 607 | class RedoIndexesForObservationViews < ActiveRecord::Migration[7.1]
def up
remove_index :observation_views, [:observation_id, :user_id],
name: :user_observation_index
add_index :observation_views, :observation_id, name: :observation_index
add_index :observation_views, :user_id, name: :use... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240608213317_update_preferred_licenses.rb | Ruby | mit | 84 | main | 213 | class UpdatePreferredLicenses < ActiveRecord::Migration[7.1]
def change
change_column_default(:images, :license_id, from: 1, to: 10)
change_column_default(:users, :license_id, from: 3, to: 10)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171216122500_clean_herbaria.rb | Ruby | mit | 84 | main | 6,136 | require "extensions.rb"
class CleanHerbaria < ActiveRecord::Migration
VALID_CODES = [
"",
"CANL",
"CFMR",
"DBG",
"ENCB",
"F",
"FH",
"FLOR",
"NMNHI",
"NY",
"OSC",
"PERTH",
"PSH",
"TAN",
"USJ"
]
def up
User.current = User.admin
# Clean out bogus... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120712121000_fix_name_ordering.rb | Ruby | mit | 84 | main | 726 | # encoding: utf-8
class FixNameOrdering < ActiveRecord::Migration
def self.up
redo_sort_names
end
def self.down
end
def self.redo_sort_names
data = []
for id, rank, text_name, author, sort_name in Name.connection.select_rows %(
SELECT id, rank, text_name, author, sort_name FROM names
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240330115758_add_missing_index_to_blocked_executions.solid_queue.rb | Ruby | mit | 84 | main | 367 | # frozen_string_literal: true
# This migration comes from solid_queue (originally 20240110143450)
class AddMissingIndexToBlockedExecutions < ActiveRecord::Migration[7.1]
def change
add_index(:solid_queue_blocked_executions,
[:concurrency_key, :priority, :job_id],
name: "index_solid_qu... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20241001191905_change_location_n_s_e_w_columns_to_decimal.rb | Ruby | mit | 84 | main | 700 | class ChangeLocationNSEWColumnsToDecimal < ActiveRecord::Migration[7.1]
def up
change_column :locations, :north, :decimal, precision: 15, scale: 10,
null: false
change_column :locations, :south, :decimal, precision: 15, scale: 10,
null: false
change_column :locations, :... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120424005558_allow_null_to_user_id.rb | Ruby | mit | 84 | main | 623 | class AllowNullToUserId < ActiveRecord::Migration
def self.up
rename_column(:queued_emails, :to_user_id, :to_user_id_old)
add_column(:queued_emails, :to_user_id, :integer)
Name.connection.update("update queued_emails set to_user_id=to_user_id_old")
remove_column(:queued_emails, :to_user_id_old)
end
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171121181200_remove_herbarium_record_when.rb | Ruby | mit | 84 | main | 200 | class RemoveHerbariumRecordWhen < ActiveRecord::Migration
def up
remove_column :herbarium_records, :when
end
def down
add_column :herbarium_records, :when, :date, null: false
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240419201108_field_slip_job_tracker_add_pages.rb | Ruby | mit | 84 | main | 395 | # frozen_string_literal: true
class FieldSlipJobTrackerAddPages < ActiveRecord::Migration[7.1]
def up
add_column(:field_slip_job_trackers, :pages, :integer,
default: 0, null: false)
FieldSlipJobTracker.connection.execute(
"UPDATE field_slip_job_trackers SET pages = count / 6"
)
end... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260405130303_respace_name_ranks.rb | Ruby | mit | 84 | main | 1,092 | class RespaceNameRanks < ActiveRecord::Migration[7.2]
OLD_TO_NEW = {
1 => 100, # Form
2 => 200, # Variety
3 => 300, # Subspecies
4 => 400, # Species
5 => 420, # Stirps
6 => 440, # Subsection
7 => 460, # Section
8 => 480, # Subgenus
9 => 500, # Genus
10 => 600,... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20121229151652_fix_curators.rb | Ruby | mit | 84 | main | 420 | class FixCurators < ActiveRecord::Migration
def self.up
# for h in Herbarium.find(:all) # Rails 3
for h in Herbarium.all
if h.curators == []
user = User.where(email: h.email)[0]
if user
h.curators.push(user)
h.save
else
print "Unable to find a user w... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20250213084440_convert_query_record_description.rb | Ruby | mit | 84 | main | 1,276 | class ConvertQueryRecordDescription < ActiveRecord::Migration[7.2]
def up
QueryRecord.find_each do |record|
str = record.instance_variable_get(:@attributes)["description"].
value_before_type_cast
description = deserialize_params(str).to_json
record.update_column(:description, descrip... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20150210013007_adjust_enum_defaults.rb | Ruby | mit | 84 | main | 1,134 | class AdjustEnumDefaults < ActiveRecord::Migration
def up
change_column_default :name_descriptions, :review_status, 1
change_column_default :users, :thumbnail_size, 1
change_column_default :users, :image_size, 3
change_column_default :users, :votes_anonymous, 1
change_column_default :users, :locat... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120507023420_add_registration_notes.rb | Ruby | mit | 84 | main | 208 | class AddRegistrationNotes < ActiveRecord::Migration
def self.up
add_column :conference_registrations, :notes, :text
end
def self.down
remove_column :conference_registrations, :notes
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260426000003_remove_classification_from_name_descriptions.rb | Ruby | mit | 84 | main | 575 | # frozen_string_literal: true
# Drop the `name_descriptions.classification` column and its
# corresponding column on the version history table. Classification
# now lives only on Name and is versioned via `name_versions`
# (discussion #4163). All read paths and the `update_classification_cache`
# callback were removed... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120814111300_add_specimen_flag_to_name_notification.rb | Ruby | mit | 84 | main | 290 | # encoding: utf-8
class AddSpecimenFlagToNameNotification < ActiveRecord::Migration
def self.up
add_column(:notifications, :require_specimen, :boolean, default: false, null: false)
rescue
nil
end
def self.down
remove_column :notifications, :require_specimen
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120409180900_image_license_history_and_transfer_record.rb | Ruby | mit | 84 | main | 792 | class ImageLicenseHistoryAndTransferRecord < ActiveRecord::Migration
def self.up
add_column :images, :transferred, :boolean, null: false, default: false
Image.connection.update "UPDATE images SET transferred = TRUE;"
create_table :copyright_changes, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: t... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240405123848_create_field_slip_job_trackers.rb | Ruby | mit | 84 | main | 293 | # frozen_string_literal: true
class CreateFieldSlipJobTrackers < ActiveRecord::Migration[7.1]
def change
create_table(:field_slip_job_trackers) do |t|
t.integer(:start)
t.integer(:count)
t.string(:prefix)
t.integer(:status)
t.timestamps
end
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120418094537_add_event_description.rb | Ruby | mit | 84 | main | 205 | class AddEventDescription < ActiveRecord::Migration
def self.up
add_column :conference_events, :description, :text
end
def self.down
remove_column :conference_events, :description
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20231208212458_add_trust_level_to_project_members.rb | Ruby | mit | 84 | main | 978 | # frozen_string_literal: true
class AddTrustLevelToProjectMembers < ActiveRecord::Migration[6.1]
def up
add_column(:project_members, :trust_level, :integer, default: 1,
null: false)
ProjectMember.find_each do |pm|
if pm.trusted
trust_leve... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240129060737_add_needs_naming_to_observations.rb | Ruby | mit | 84 | main | 431 | class AddNeedsNamingToObservations < ActiveRecord::Migration[7.1]
def up
add_column :observations, :needs_naming, :boolean, default: false,
null: false
add_index :observations, :needs_naming, name: :needs_naming_index
end
def down
remove_index :o... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240330115759_create_recurring_executions.solid_queue.rb | Ruby | mit | 84 | main | 620 | # frozen_string_literal: true
# This migration comes from solid_queue (originally 20240218110712)
class CreateRecurringExecutions < ActiveRecord::Migration[7.1]
def change
create_table(:solid_queue_recurring_executions) do |t|
t.references(:job, index: { unique: true }, null: false)
t.string(:task_ke... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20230831162829_add_open_membership_to_projects.rb | Ruby | mit | 84 | main | 256 | # frozen_string_literal: true
class AddOpenMembershipToProjects < ActiveRecord::Migration[6.1]
def change
add_column(:projects, :open_membership, :boolean, default: false,
null: false)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240802092653_remove_tmp_fields_from_field_slip_job_trackers.rb | Ruby | mit | 84 | main | 254 | # frozen_string_literal: true
class RemoveTmpFieldsFromFieldSlipJobTrackers < ActiveRecord::Migration[7.1]
def change
remove_column(:field_slip_job_trackers, :notes, :text)
remove_column(:field_slip_job_trackers, :version, :integer)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240310132813_create_field_slips.rb | Ruby | mit | 84 | main | 320 | # frozen_string_literal: true
class CreateFieldSlips < ActiveRecord::Migration[7.1]
def change
create_table(:field_slips) do |t|
t.integer(:observation_id)
t.integer(:project_id)
t.string(:code, null: false)
t.timestamps
end
add_index(:field_slips, :code, unique: true)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220614003912_add_primary_key_to_glossary_terms_images.rb | Ruby | mit | 84 | main | 218 | class AddPrimaryKeyToGlossaryTermsImages < ActiveRecord::Migration[6.1]
def change
rename_table("glossary_terms_images", "glossary_term_images")
add_column(:glossary_term_images, :id, :primary_key)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20140125225358_create_publications.rb | Ruby | mit | 84 | main | 404 | class CreatePublications < ActiveRecord::Migration
def self.up
create_table :publications, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: true do |t|
t.integer :user_id
t.text :full
t.string :link
t.text :how_helped
t.boolean :mo_mentioned
t.boolean :peer_reviewed
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20220613151300_add_primary_key_and_rank_to_images_observations.rb | Ruby | mit | 84 | main | 296 | class AddPrimaryKeyAndRankToImagesObservations < ActiveRecord::Migration[5.2]
def change
rename_table("images_observations", "observation_images")
add_column(:observation_images, :id, :primary_key)
add_column(:observation_images, :rank, :integer, default: 0, null: false)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20141021184347_term_to_glossary_term.rb | Ruby | mit | 84 | main | 2,725 | class TermToGlossaryTerm < ActiveRecord::Migration
RENAME_STRINGS = {
term: :glossary_term,
TERM: :GLOSSARY_TERM,
TERMS: :GLOSSARY_TERMS,
terms: :glossary_terms,
log_term_created_at: :log_glossary_term_created_at,
log_term_updated_at: :log_glossary_term_updated_at,
term_created_at: :glossa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.