From 230ab3079fd4e16ebaa593f6cc5fdbcbad3c2321 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 10 Dec 2022 12:32:44 -0500 Subject: Installed LINGO scoreboard --- ..._name_to_active_storage_blobs.active_storage.rb | 22 ++++++++++++++++++ ...ctive_storage_variant_records.active_storage.rb | 27 ++++++++++++++++++++++ ...active_storage_blobs_checksum.active_storage.rb | 8 +++++++ .../20221210170549_create_lingo_scores.lingo.rb | 13 +++++++++++ 4 files changed, 70 insertions(+) create mode 100644 db/migrate/20221210170526_add_service_name_to_active_storage_blobs.active_storage.rb create mode 100644 db/migrate/20221210170527_create_active_storage_variant_records.active_storage.rb create mode 100644 db/migrate/20221210170528_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb create mode 100644 db/migrate/20221210170549_create_lingo_scores.lingo.rb (limited to 'db/migrate') diff --git a/db/migrate/20221210170526_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20221210170526_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 0000000..a15c6ce --- /dev/null +++ b/db/migrate/20221210170526_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,22 @@ +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + return unless table_exists?(:active_storage_blobs) + + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end + + def down + return unless table_exists?(:active_storage_blobs) + + remove_column :active_storage_blobs, :service_name + end +end diff --git a/db/migrate/20221210170527_create_active_storage_variant_records.active_storage.rb b/db/migrate/20221210170527_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 0000000..94ac83a --- /dev/null +++ b/db/migrate/20221210170527_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + # Use Active Record's configured type for primary key + create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| + t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type + t.string :variation_digest, null: false + + t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end +end diff --git a/db/migrate/20221210170528_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/db/migrate/20221210170528_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb new file mode 100644 index 0000000..93c8b85 --- /dev/null +++ b/db/migrate/20221210170528_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb @@ -0,0 +1,8 @@ +# This migration comes from active_storage (originally 20211119233751) +class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + change_column_null(:active_storage_blobs, :checksum, true) + end +end diff --git a/db/migrate/20221210170549_create_lingo_scores.lingo.rb b/db/migrate/20221210170549_create_lingo_scores.lingo.rb new file mode 100644 index 0000000..f56790f --- /dev/null +++ b/db/migrate/20221210170549_create_lingo_scores.lingo.rb @@ -0,0 +1,13 @@ +# This migration comes from lingo (originally 20221210011146) +class CreateLingoScores < ActiveRecord::Migration[7.0] + def change + create_table :lingo_scores do |t| + t.integer :user_id + t.string :username + t.string :avatar_url + t.integer :score + + t.timestamps + end + end +end -- cgit 1.4.1