From 978217b3bee2a0334c76722c4dc9f8a541d29bf4 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Sun, 22 Nov 2026 01:58:58 +0100 Subject: [PATCH] Discontinue MySQL support This is intended to reduce development effort. Support may be reintroduced later, if justified. --- .gitignore | 7 +- DESIGN.md | 11 +++ Gemfile | 22 ++---- Gemfile.lock | 11 --- README.md | 49 ++---------- config/database.yml.dist | 56 ++------------ config/initializers/core_ext.rb | 1 + db/schema.rb | 40 +++++----- db/sqlite3_schema.rb | 103 ------------------------- lib/core_ext/arel/visitors/s_q_lite.rb | 10 +++ lib/core_ext/arel/visitors/to_sql.rb | 9 --- lib/default_settings_strategy.rb | 14 ++-- test/application_system_test_case.rb | 47 +++++------ 13 files changed, 88 insertions(+), 292 deletions(-) delete mode 100644 db/sqlite3_schema.rb create mode 100644 lib/core_ext/arel/visitors/s_q_lite.rb diff --git a/.gitignore b/.gitignore index 02961fb..f8183a2 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,10 @@ /config/master.key /config/puma.rb -# Ignore test database. -/db/test.sqlite3 +# Ignore database files. +/db/*.sqlite3 +/db/*.sqlite3-shm +/db/*.sqlite3-wal # Ignore all logfiles and tempfiles. /log/* @@ -46,5 +48,6 @@ /.vim /.viminfo /.webdrivers +/.wget-hsts *.swp Session.vim diff --git a/DESIGN.md b/DESIGN.md index 98e554d..4f21d8d 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -4,6 +4,17 @@ DESIGN Below is a list of design decisions. The justification is to be consulted whenever a change is considered, to avoid regressions. +### Database engine support + +* currently, only SQLite is supported; the reasons for not supporting other + engines under consideration are outlined below: + * MariaDB: + * lack of support for Common Table Expressions (CTEs) in UPDATE and + DELETE statements (https://jira.mariadb.org/browse/MDEV-18511), + * MySQL: + * lack of support for the ORDER BY clause within recursive CTEs - which + makes it difficult to sort hierarchies using a depth-first approach. + ### Data type for DB storage of numeric values (`decimal` vs `float`) * among database engines supported (by Rails), SQLite offers storage of diff --git a/Gemfile b/Gemfile index fd5ced4..8854069 100644 --- a/Gemfile +++ b/Gemfile @@ -5,21 +5,9 @@ gem "rails", "~> 8.1.4" gem "sprockets-rails" gem "puma", "~> 6.0" gem "sassc-rails" -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem. gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] - -# TODO: select db gems automatically? -# database_config = ERB.new(File.read("config/database.yml")).result -# YAML.load(database_config, aliases: true).values.map { |env| env["adapter"] }.uniq -group :mysql, optional: true do - gem "mysql2", "~> 0.5" -end -group :postgresql, optional: true do - gem "pg", "~> 1.5" -end -group :sqlite, optional: true do - gem "sqlite3", "~> 2.7" -end +gem "sqlite3", "~> 2.7" gem "devise", "~> 5.0.4" @@ -31,15 +19,15 @@ group :development, :test do end group :development do - # Use console on exceptions pages [https://github.com/rails/web-console] + # Use console on exceptions pages [https://github.com/rails/web-console]. gem "web-console" - # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] + # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]. # gem "rack-mini-profiler" end group :test do - # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] + # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]. # TODO: move back from git after this PR is included: # https://github.com/teamcapybara/capybara/pull/2862 gem "capybara", git: "https://github.com/teamcapybara/capybara", branch: "table_row-optional-header-and-integer-locator" diff --git a/Gemfile.lock b/Gemfile.lock index 7d43450..0a18b4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -157,8 +157,6 @@ GEM minitest (6.0.6) drb (~> 2.0) prism (~> 1.5) - mysql2 (0.5.7) - bigdecimal net-imap (0.6.7) date net-protocol @@ -186,13 +184,6 @@ GEM nokogiri (1.19.4-x86_64-linux-musl) racc (~> 1.4) orm_adapter (0.5.0) - pg (1.7.0) - pg (1.7.0-aarch64-linux) - pg (1.7.0-aarch64-linux-musl) - pg (1.7.0-arm64-darwin) - pg (1.7.0-x86_64-darwin) - pg (1.7.0-x86_64-linux) - pg (1.7.0-x86_64-linux-musl) pp (0.6.4) prettyprint prettyprint (0.2.0) @@ -328,8 +319,6 @@ DEPENDENCIES devise (~> 5.0.4) i18n! importmap-rails - mysql2 (~> 0.5) - pg (~> 1.5) puma (~> 6.0) rails (~> 8.1.4) sassc-rails diff --git a/README.md b/README.md index f17f3ef..0a70c1c 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,6 @@ environment, see the _Contributing_ section below. * Server side: * Ruby interpreter, depending on the version of Rails used (see _Gemfile_), * https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#ruby-versions - * database (e.g. SQLite, MySQL >= 8.0) supporting: - * recursive Common Table Expressions (CTE) for SELECT/UPDATE/DELETE, - * MariaDB does not support CTE for UPDATE/DELETE - (https://jira.mariadb.org/browse/MDEV-18511) * for testing: browser as specified in _Client side_ requirements * Client side: * browser (e.g. Firefox >= 121) supporting: @@ -30,20 +26,14 @@ environment, see the _Contributing_ section below. ### Gems On systems where development tools and libraries are not installed by default -(such as Ubuntu), you should install them before proceeding with Ruby gems. -Select the database client library according to the database engine you are -planning to use: +(such as Ubuntu), you should install them before proceeding with Ruby gems: - sudo apt install build-essential libyaml-dev libmysqlclient-dev + sudo apt install build-essential libyaml-dev git clone https://gitea.michalczyk.pro/fixin.me/fixin.me.git cd fixin.me bundle config --local frozen true bundle config --local path .gem - -Select which database engine gem to install (mysql, postgresql, sqlite): - - bundle config --local with mysql bundle install ### Configuration @@ -64,13 +54,6 @@ Precompile assets: ### Database -Grant database user and privileges: - - > mysql -p - mysql> create user fixinme@localhost identified by 'Some-password1%'; - mysql> grant all privileges on fixinme.* to fixinme@localhost; - mysql> flush privileges; - Copy config template and update database configuration: cp -a config/database.yml.dist config/database.yml @@ -115,10 +98,9 @@ Contributing ### Gems -Install development and testing gems, including at least MySQL and SQLite -database adapters: +Install development and testing gems: - bundle config --local with development test mysql sqlite + bundle config --local with development test #### Using gems from local git repos @@ -147,18 +129,9 @@ assets. ### Database -Grant database user privileges for development and test environments. Example -below shows how to grant privileges to all databases which names start with -`fixinme-` on MySQL: - - > mysql -p - mysql> create user `fixinme-dev`@localhost identified by ''; - mysql> grant all privileges on `fixinme-%`.* to `fixinme-dev`@localhost; - mysql> flush privileges; - Dumping development data before database reset: - mysqldump -h
-u -p --no-create-info --no-tablespaces --complete-insert > tmp/data.sql + TODO ### Development environment @@ -166,10 +139,6 @@ Starting application server in development environment: bundle exec rails s -e development -Accessing database console when more than one test db is present: - - bundle exec rails dbconsole -e test --db sqlite3 - For running rake tasks, prepend command with environment: RAILS_ENV=development bundle exec rails ... @@ -190,14 +159,6 @@ Tests need to be run from within toplevel application directory: bundle exec rails test test/system/users_test.rb --seed 1234 -* system tests for selected database configuration (if multiple present): - - bundle exec rails test:system --include /^test_sqlite3_/ - -* single system test for all database configurations (if multiple present): - - bundle exec rails test:system --include /^test_\\w+_add_unit$/ - ### Icons Pictogrammers Material Design Icons: https://pictogrammers.com/library/mdi/ diff --git a/config/database.yml.dist b/config/database.yml.dist index 25c80c4..386f01d 100644 --- a/config/database.yml.dist +++ b/config/database.yml.dist @@ -1,39 +1,8 @@ -# If you don't want to store sensitive information, like your database password, -# in your source code, provide the password or a full connection URL as an -# environment variable when you boot the app. For example: -# -# DATABASE_PASSWORD="Some-password1%" -# -# or -# -# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" -# -# If the connection URL is provided in the special DATABASE_URL environment -# variable, Rails will automatically merge its configuration values on top of -# the values provided in this file. Alternatively, you can specify a connection -# URL environment variable explicitly: -# -# production: -# url: <%= ENV["MY_APP_DATABASE_URL"] %> -# -# You can specify password environment variable in a similar way: -# -# production: -# password: <%= ENV["DATABASE_PASSWORD"] %> -# # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full overview on how database connection configuration can be specified. default: &default pool: <%= ENV.fetch('RAILS_MAX_THREADS', 3) %> -#mysql_default: &mysql_default -# <<: *default -# username: fixinme -# password: Some-password1% -# host: 127.0.0.1 -# encoding: utf8mb4 -# collation: utf8mb4_0900_as_ci - production: <<: *default adapter: sqlite3 @@ -42,27 +11,14 @@ production: # Unless you're planning on developing the application, you can skip/remove # configurations for development and test databases altogether. #development: -# <<: *mysql_default -# adapter: mysql2 -# database: fixinme_dev +# <<: *default +# adapter: sqlite3 +# database: db/development.sqlite3 # Warning: The database(s) defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. #test: -# <<: *mysql_default -# adapter: mysql2 -# database: fixinme_test - -# Multiple test databases can be provided. When more than one test db is -# present, every test task (test, test:models, test:system, etc.) runs against -# all of them. -#test: -# mysql2: -# <<: *mysql_default -# adapter: mysql2 -# database: fixinme_test -# sqlite3: -# <<: *default -# adapter: sqlite3 -# database: db/test.sqlite3 +# <<: *default +# adapter: sqlite3 +# database: db/test.sqlite3 diff --git a/config/initializers/core_ext.rb b/config/initializers/core_ext.rb index 2cde793..4752387 100644 --- a/config/initializers/core_ext.rb +++ b/config/initializers/core_ext.rb @@ -24,6 +24,7 @@ ActiveSupport.on_load :active_record do Arel::SelectManager.prepend CoreExt::Arel::SelectManager Arel::TreeManager::StatementMethods .prepend CoreExt::Arel::TreeManager::StatementMethods + Arel::Visitors::SQLite.prepend CoreExt::Arel::Visitors::SQLite Arel::Visitors::ToSql.prepend CoreExt::Arel::Visitors::ToSql # Currently not included patches for: diff --git a/db/schema.rb b/db/schema.rb index 84650cc..0d1533a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,27 +10,27 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2025_01_21_230456) do - create_table "measurements", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t| +ActiveRecord::Schema[8.1].define(version: 2026_11_07_214900) do + create_table "measurements", force: :cascade do |t| t.datetime "taken_at", null: false - t.bigint "note_id" + t.integer "note_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["note_id"], name: "index_measurements_on_note_id" t.index ["taken_at"], name: "index_measurements_on_taken_at", unique: true end - create_table "notes", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t| - t.text "text", null: false + create_table "notes", force: :cascade do |t| + t.text "text", limit: 65535, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "quantities", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t| - t.bigint "user_id" + create_table "quantities", force: :cascade do |t| + t.integer "user_id" t.string "name", limit: 31, null: false - t.text "description" - t.bigint "parent_id" + t.text "description", limit: 65535 + t.integer "parent_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "depth", default: 0, null: false @@ -41,30 +41,28 @@ ActiveRecord::Schema[8.1].define(version: 2025_01_21_230456) do t.index ["user_id"], name: "index_quantities_on_user_id" end - create_table "readouts", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t| - t.bigint "user_id", null: false - t.bigint "measurement_id" - t.bigint "quantity_id", null: false + create_table "readouts", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "measurement_id" + t.integer "quantity_id", null: false t.integer "category", default: 0, null: false t.float "value", limit: 53, null: false - t.bigint "unit_id", null: false + t.integer "unit_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["measurement_id", "quantity_id", "category"], name: "index_readouts_on_measurement_id_and_quantity_id_and_category", unique: true t.index ["measurement_id"], name: "index_readouts_on_measurement_id" - t.index ["quantity_id", "user_id"], name: "fk_rails_9d92eaafc6" t.index ["quantity_id"], name: "index_readouts_on_quantity_id" - t.index ["unit_id", "user_id"], name: "fk_rails_348b0fb4c5" t.index ["unit_id"], name: "index_readouts_on_unit_id" t.index ["user_id"], name: "index_readouts_on_user_id" end - create_table "units", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t| - t.bigint "user_id" + create_table "units", force: :cascade do |t| + t.integer "user_id" t.string "symbol", limit: 15, null: false - t.text "description" + t.text "description", limit: 65535 t.float "multiplier", limit: 53, default: 1.0, null: false - t.bigint "base_id" + t.integer "base_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["base_id"], name: "index_units_on_base_id" @@ -73,7 +71,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_01_21_230456) do t.index ["user_id"], name: "index_units_on_user_id" end - create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t| + create_table "users", force: :cascade do |t| t.string "email", limit: 64, null: false t.integer "status", default: 0, null: false t.datetime "created_at", null: false diff --git a/db/sqlite3_schema.rb b/db/sqlite3_schema.rb deleted file mode 100644 index ea32ab5..0000000 --- a/db/sqlite3_schema.rb +++ /dev/null @@ -1,103 +0,0 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[8.1].define(version: 2025_01_21_230456) do - create_table "measurements", force: :cascade do |t| - t.datetime "taken_at", null: false - t.integer "note_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["note_id"], name: "index_measurements_on_note_id" - t.index ["taken_at"], name: "index_measurements_on_taken_at", unique: true - end - - create_table "notes", force: :cascade do |t| - t.text "text", limit: 65535, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "quantities", force: :cascade do |t| - t.integer "user_id" - t.string "name", limit: 31, null: false - t.text "description", limit: 65535 - t.integer "parent_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "depth", default: 0, null: false - t.string "pathname", limit: 511, null: false - t.index ["id", "user_id"], name: "index_quantities_on_id_and_user_id", unique: true - t.index ["parent_id"], name: "index_quantities_on_parent_id" - t.index ["user_id", "parent_id", "name"], name: "index_quantities_on_user_id_and_parent_id_and_name", unique: true - t.index ["user_id"], name: "index_quantities_on_user_id" - end - - create_table "readouts", force: :cascade do |t| - t.integer "user_id", null: false - t.integer "measurement_id" - t.integer "quantity_id", null: false - t.integer "category", default: 0, null: false - t.float "value", limit: 53, null: false - t.integer "unit_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["measurement_id", "quantity_id", "category"], name: "index_readouts_on_measurement_id_and_quantity_id_and_category", unique: true - t.index ["measurement_id"], name: "index_readouts_on_measurement_id" - t.index ["quantity_id"], name: "index_readouts_on_quantity_id" - t.index ["unit_id"], name: "index_readouts_on_unit_id" - t.index ["user_id"], name: "index_readouts_on_user_id" - end - - create_table "units", force: :cascade do |t| - t.integer "user_id" - t.string "symbol", limit: 15, null: false - t.text "description", limit: 65535 - t.float "multiplier", limit: 53, default: 1.0, null: false - t.integer "base_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["base_id"], name: "index_units_on_base_id" - t.index ["id", "user_id"], name: "index_units_on_id_and_user_id", unique: true - t.index ["user_id", "symbol"], name: "index_units_on_user_id_and_symbol", unique: true - t.index ["user_id"], name: "index_units_on_user_id" - end - - create_table "users", force: :cascade do |t| - t.string "email", limit: 64, null: false - t.integer "status", default: 0, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email", limit: 64 - t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true - t.index ["email"], name: "index_users_on_email", unique: true - t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true - end - - add_foreign_key "measurements", "notes", on_delete: :nullify - add_foreign_key "quantities", "quantities", column: "parent_id", on_delete: :cascade - add_foreign_key "quantities", "users", on_delete: :cascade - add_foreign_key "readouts", "measurements", on_delete: :cascade - add_foreign_key "readouts", "quantities", column: ["quantity_id", "user_id"], primary_key: ["id", "user_id"] - add_foreign_key "readouts", "quantities", on_delete: :cascade - add_foreign_key "readouts", "units", column: ["unit_id", "user_id"], primary_key: ["id", "user_id"] - add_foreign_key "readouts", "units", on_delete: :cascade - add_foreign_key "readouts", "users", on_delete: :cascade - add_foreign_key "units", "units", column: "base_id", on_delete: :cascade - add_foreign_key "units", "users", on_delete: :cascade -end diff --git a/lib/core_ext/arel/visitors/s_q_lite.rb b/lib/core_ext/arel/visitors/s_q_lite.rb new file mode 100644 index 0000000..47cdab5 --- /dev/null +++ b/lib/core_ext/arel/visitors/s_q_lite.rb @@ -0,0 +1,10 @@ +module CoreExt::Arel::Visitors::SQLite + def visit_Arel_Nodes_UpdateStatement(o, collector) + if o.with + collector = visit o.with, collector + collector << " " + end + + super + end +end diff --git a/lib/core_ext/arel/visitors/to_sql.rb b/lib/core_ext/arel/visitors/to_sql.rb index 87ade0e..d74a756 100644 --- a/lib/core_ext/arel/visitors/to_sql.rb +++ b/lib/core_ext/arel/visitors/to_sql.rb @@ -7,13 +7,4 @@ module CoreExt::Arel::Visitors::ToSql super end - - def visit_Arel_Nodes_UpdateStatement(o, collector) - if o.with - collector = visit o.with, collector - collector << " " - end - - super - end end diff --git a/lib/default_settings_strategy.rb b/lib/default_settings_strategy.rb index 35abbf1..df80bf1 100644 --- a/lib/default_settings_strategy.rb +++ b/lib/default_settings_strategy.rb @@ -2,12 +2,12 @@ class DefaultSettingsStrategy < ActiveRecord::Migration::DefaultStrategy COLUMN_DEFAULTS = { # TODO: all types `null: false` ? # TODO: references `foreign_key: {on_delete: :cascade}` ? - # `timestamps` - Rails defaults to `null: false, precision: true`. + # `timestamps` - Rails defaults to `null: false, precision: true`, which is + # expected. # `limit:` for `text` - `text` can be theoretically up to 1GB or # longer, so roughly unlimited for practical purposes. But: # * the actual usable length depends on additional factors, like compile - # time limits (`SQLITE_MAX_LENGTH` in SQLite), runtime settings - # (`max_allowed_packet` in MySQL) and probably other, + # time limits (`SQLITE_MAX_LENGTH` in SQLite) and probably other, # * Rails does not report limit for `text` column types, unless it is # explicitly set. # The decision is to always set safe limit and enforce it by validations, to @@ -24,20 +24,20 @@ class DefaultSettingsStrategy < ActiveRecord::Migration::DefaultStrategy end ActiveRecord::ConnectionAdapters::TableDefinition.prepend ColumnSettingsStrategy - # `force: :cascade` - does nothing on MySQL, so `force:` is useless. # `if_not_exists: true`/`if_exists: true` - without these options it's impossible # to change migration status once migration fails partially. If `up` migration # creates some, but not all objects, its status is not updated from `down` to # `up`. Then it's impossible to migrate: a) up - due to `already exists` - # errors and b) down - due to migration status. + # errors and b) down - due to migration status. Similarily for `down`. MIGRATION_DEFAULTS = { add_check_constraint: {if_not_exists: true}, add_column: {if_not_exists: true}, add_foreign_key: {if_not_exists: true}, add_index: {if_not_exists: true, unique: true}, add_timestamps: {if_not_exists: true}, - create_table: {if_not_exists: true}, - drop_table: {if_exists: true}, + create_join_table: {force: :cascade}, + create_table: {force: :cascade}, + drop_table: {force: :cascade}, remove_check_constraint: {if_exists: true}, remove_column: {if_exists: true}, remove_foreign_key: {if_exists: true}, diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 916ccbf..5af18b8 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -4,7 +4,7 @@ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase include ActionView::Helpers::UrlHelper - # NOTE: geckodriver installed with Firefox, ignore incompatibility warning + # `geckodriver` installed with Firefox, ignore incompatibility warning. Selenium::WebDriver.logger .ignore(:selenium_manager, :clear_session_storage, :clear_local_storage) @@ -33,33 +33,24 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase button.html_safe) end - DB_CONFIGS = ActiveRecord::Base.configurations.configs_for(env_name: "test") - TEST_CONFIGS = Hash.new(DB_CONFIGS.first.name.to_sym) - class << self - # NOTE: alternative to current solution is to create shards: - # ActiveRecord::Base.connects_to( - # shards: {mysql2: {writing: :mysql2}, sqlite3: {writing: :sqlite3}} - # ) - # and use them in one of the following ways: - # * set config.active_record.shard_selector/shard_resolver - # * run tests within: ActiveRecord::Base.connected_to(shard: :sqlite3) { test_ } - # Remove this note once current solution is confirmed to work. - # - # Test block should not be modified here, as it would change its binding from - # instance level to class level. - # TODO: allow multiple iterations of tests? would require saving seed in - # #setup to make reproducing easier - if DB_CONFIGS.many? - def test(name, ...) - DB_CONFIGS.each do |config| - TEST_CONFIGS[super("#{config.name} #{name}", ...)] = config.name.to_sym - end - end - end - end - setup do - ActiveRecord::Base.establish_connection(TEST_CONFIGS[name.to_sym]) - end + #DB_CONFIGS = ActiveRecord::Base.configurations.configs_for(env_name: "test") + #TEST_CONFIGS = Hash.new(DB_CONFIGS.first.name.to_sym) + #class << self + # # Test block should not be modified here, as it would change its binding from + # # instance level to class level. + # # TODO: allow multiple iterations of tests? would require saving seed in + # # #setup to make reproducing easier + # if DB_CONFIGS.many? + # def test(name, ...) + # DB_CONFIGS.each do |config| + # TEST_CONFIGS[super("#{config.name} #{name}", ...)] = config.name.to_sym + # end + # end + # end + #end + #setup do + # ActiveRecord::Base.establish_connection(TEST_CONFIGS[name.to_sym]) + #end Capybara.modify_selector(:link) do expression_filter(:disabled) do |xpath, value|