forked from fixin.me/fixin.me
Discontinue MySQL support
This is intended to reduce development effort. Support may be reintroduced later, if justified.
This commit is contained in:
+5
-2
@@ -15,8 +15,10 @@
|
|||||||
/config/master.key
|
/config/master.key
|
||||||
/config/puma.rb
|
/config/puma.rb
|
||||||
|
|
||||||
# Ignore test database.
|
# Ignore database files.
|
||||||
/db/test.sqlite3
|
/db/*.sqlite3
|
||||||
|
/db/*.sqlite3-shm
|
||||||
|
/db/*.sqlite3-wal
|
||||||
|
|
||||||
# Ignore all logfiles and tempfiles.
|
# Ignore all logfiles and tempfiles.
|
||||||
/log/*
|
/log/*
|
||||||
@@ -46,5 +48,6 @@
|
|||||||
/.vim
|
/.vim
|
||||||
/.viminfo
|
/.viminfo
|
||||||
/.webdrivers
|
/.webdrivers
|
||||||
|
/.wget-hsts
|
||||||
*.swp
|
*.swp
|
||||||
Session.vim
|
Session.vim
|
||||||
|
|||||||
@@ -4,6 +4,17 @@ DESIGN
|
|||||||
Below is a list of design decisions. The justification is to be consulted
|
Below is a list of design decisions. The justification is to be consulted
|
||||||
whenever a change is considered, to avoid regressions.
|
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`)
|
### Data type for DB storage of numeric values (`decimal` vs `float`)
|
||||||
|
|
||||||
* among database engines supported (by Rails), SQLite offers storage of
|
* among database engines supported (by Rails), SQLite offers storage of
|
||||||
|
|||||||
@@ -5,21 +5,9 @@ gem "rails", "~> 8.1.4"
|
|||||||
gem "sprockets-rails"
|
gem "sprockets-rails"
|
||||||
gem "puma", "~> 6.0"
|
gem "puma", "~> 6.0"
|
||||||
gem "sassc-rails"
|
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 ]
|
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"
|
gem "sqlite3", "~> 2.7"
|
||||||
end
|
|
||||||
|
|
||||||
gem "devise", "~> 5.0.4"
|
gem "devise", "~> 5.0.4"
|
||||||
|
|
||||||
@@ -31,15 +19,15 @@ group :development, :test do
|
|||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
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"
|
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"
|
# gem "rack-mini-profiler"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
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:
|
# TODO: move back from git after this PR is included:
|
||||||
# https://github.com/teamcapybara/capybara/pull/2862
|
# https://github.com/teamcapybara/capybara/pull/2862
|
||||||
gem "capybara", git: "https://github.com/teamcapybara/capybara", branch: "table_row-optional-header-and-integer-locator"
|
gem "capybara", git: "https://github.com/teamcapybara/capybara", branch: "table_row-optional-header-and-integer-locator"
|
||||||
|
|||||||
@@ -157,8 +157,6 @@ GEM
|
|||||||
minitest (6.0.6)
|
minitest (6.0.6)
|
||||||
drb (~> 2.0)
|
drb (~> 2.0)
|
||||||
prism (~> 1.5)
|
prism (~> 1.5)
|
||||||
mysql2 (0.5.7)
|
|
||||||
bigdecimal
|
|
||||||
net-imap (0.6.7)
|
net-imap (0.6.7)
|
||||||
date
|
date
|
||||||
net-protocol
|
net-protocol
|
||||||
@@ -186,13 +184,6 @@ GEM
|
|||||||
nokogiri (1.19.4-x86_64-linux-musl)
|
nokogiri (1.19.4-x86_64-linux-musl)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
orm_adapter (0.5.0)
|
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)
|
pp (0.6.4)
|
||||||
prettyprint
|
prettyprint
|
||||||
prettyprint (0.2.0)
|
prettyprint (0.2.0)
|
||||||
@@ -328,8 +319,6 @@ DEPENDENCIES
|
|||||||
devise (~> 5.0.4)
|
devise (~> 5.0.4)
|
||||||
i18n!
|
i18n!
|
||||||
importmap-rails
|
importmap-rails
|
||||||
mysql2 (~> 0.5)
|
|
||||||
pg (~> 1.5)
|
|
||||||
puma (~> 6.0)
|
puma (~> 6.0)
|
||||||
rails (~> 8.1.4)
|
rails (~> 8.1.4)
|
||||||
sassc-rails
|
sassc-rails
|
||||||
|
|||||||
@@ -16,10 +16,6 @@ environment, see the _Contributing_ section below.
|
|||||||
* Server side:
|
* Server side:
|
||||||
* Ruby interpreter, depending on the version of Rails used (see _Gemfile_),
|
* Ruby interpreter, depending on the version of Rails used (see _Gemfile_),
|
||||||
* https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#ruby-versions
|
* 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
|
* for testing: browser as specified in _Client side_ requirements
|
||||||
* Client side:
|
* Client side:
|
||||||
* browser (e.g. Firefox >= 121) supporting:
|
* browser (e.g. Firefox >= 121) supporting:
|
||||||
@@ -30,20 +26,14 @@ environment, see the _Contributing_ section below.
|
|||||||
### Gems
|
### Gems
|
||||||
|
|
||||||
On systems where development tools and libraries are not installed by default
|
On systems where development tools and libraries are not installed by default
|
||||||
(such as Ubuntu), you should install them before proceeding with Ruby gems.
|
(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:
|
|
||||||
|
|
||||||
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
|
git clone https://gitea.michalczyk.pro/fixin.me/fixin.me.git
|
||||||
cd fixin.me
|
cd fixin.me
|
||||||
bundle config --local frozen true
|
bundle config --local frozen true
|
||||||
bundle config --local path .gem
|
bundle config --local path .gem
|
||||||
|
|
||||||
Select which database engine gem to install (mysql, postgresql, sqlite):
|
|
||||||
|
|
||||||
bundle config --local with mysql
|
|
||||||
bundle install
|
bundle install
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
@@ -64,13 +54,6 @@ Precompile assets:
|
|||||||
|
|
||||||
### Database
|
### 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:
|
Copy config template and update database configuration:
|
||||||
|
|
||||||
cp -a config/database.yml.dist config/database.yml
|
cp -a config/database.yml.dist config/database.yml
|
||||||
@@ -115,10 +98,9 @@ Contributing
|
|||||||
|
|
||||||
### Gems
|
### Gems
|
||||||
|
|
||||||
Install development and testing gems, including at least MySQL and SQLite
|
Install development and testing gems:
|
||||||
database adapters:
|
|
||||||
|
|
||||||
bundle config --local with development test mysql sqlite
|
bundle config --local with development test
|
||||||
|
|
||||||
#### Using gems from local git repos
|
#### Using gems from local git repos
|
||||||
|
|
||||||
@@ -147,18 +129,9 @@ assets.
|
|||||||
|
|
||||||
### Database
|
### 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 '<some password>';
|
|
||||||
mysql> grant all privileges on `fixinme-%`.* to `fixinme-dev`@localhost;
|
|
||||||
mysql> flush privileges;
|
|
||||||
|
|
||||||
Dumping development data before database reset:
|
Dumping development data before database reset:
|
||||||
|
|
||||||
mysqldump -h <address> -u <user> -p --no-create-info --no-tablespaces --complete-insert <database> > tmp/data.sql
|
TODO
|
||||||
|
|
||||||
### Development environment
|
### Development environment
|
||||||
|
|
||||||
@@ -166,10 +139,6 @@ Starting application server in development environment:
|
|||||||
|
|
||||||
bundle exec rails s -e development
|
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:
|
For running rake tasks, prepend command with environment:
|
||||||
|
|
||||||
RAILS_ENV=development bundle exec rails ...
|
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
|
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
|
### Icons
|
||||||
|
|
||||||
Pictogrammers Material Design Icons: https://pictogrammers.com/library/mdi/
|
Pictogrammers Material Design Icons: https://pictogrammers.com/library/mdi/
|
||||||
|
|||||||
@@ -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
|
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
|
||||||
# for a full overview on how database connection configuration can be specified.
|
# for a full overview on how database connection configuration can be specified.
|
||||||
default: &default
|
default: &default
|
||||||
pool: <%= ENV.fetch('RAILS_MAX_THREADS', 3) %>
|
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:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
adapter: sqlite3
|
adapter: sqlite3
|
||||||
@@ -42,27 +11,14 @@ production:
|
|||||||
# Unless you're planning on developing the application, you can skip/remove
|
# Unless you're planning on developing the application, you can skip/remove
|
||||||
# configurations for development and test databases altogether.
|
# configurations for development and test databases altogether.
|
||||||
#development:
|
#development:
|
||||||
# <<: *mysql_default
|
# <<: *default
|
||||||
# adapter: mysql2
|
# adapter: sqlite3
|
||||||
# database: fixinme_dev
|
# database: db/development.sqlite3
|
||||||
|
|
||||||
# Warning: The database(s) defined as "test" will be erased and
|
# Warning: The database(s) defined as "test" will be erased and
|
||||||
# re-generated from your development database when you run "rake".
|
# re-generated from your development database when you run "rake".
|
||||||
# Do not set this db to the same as development or production.
|
# Do not set this db to the same as development or production.
|
||||||
#test:
|
#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
|
# <<: *default
|
||||||
# adapter: sqlite3
|
# adapter: sqlite3
|
||||||
# database: db/test.sqlite3
|
# database: db/test.sqlite3
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ ActiveSupport.on_load :active_record do
|
|||||||
Arel::SelectManager.prepend CoreExt::Arel::SelectManager
|
Arel::SelectManager.prepend CoreExt::Arel::SelectManager
|
||||||
Arel::TreeManager::StatementMethods
|
Arel::TreeManager::StatementMethods
|
||||||
.prepend CoreExt::Arel::TreeManager::StatementMethods
|
.prepend CoreExt::Arel::TreeManager::StatementMethods
|
||||||
|
Arel::Visitors::SQLite.prepend CoreExt::Arel::Visitors::SQLite
|
||||||
Arel::Visitors::ToSql.prepend CoreExt::Arel::Visitors::ToSql
|
Arel::Visitors::ToSql.prepend CoreExt::Arel::Visitors::ToSql
|
||||||
|
|
||||||
# Currently not included patches for:
|
# Currently not included patches for:
|
||||||
|
|||||||
+19
-21
@@ -10,27 +10,27 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
ActiveRecord::Schema[8.1].define(version: 2026_11_07_214900) do
|
||||||
create_table "measurements", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t|
|
create_table "measurements", force: :cascade do |t|
|
||||||
t.datetime "taken_at", null: false
|
t.datetime "taken_at", null: false
|
||||||
t.bigint "note_id"
|
t.integer "note_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.index ["note_id"], name: "index_measurements_on_note_id"
|
t.index ["note_id"], name: "index_measurements_on_note_id"
|
||||||
t.index ["taken_at"], name: "index_measurements_on_taken_at", unique: true
|
t.index ["taken_at"], name: "index_measurements_on_taken_at", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "notes", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t|
|
create_table "notes", force: :cascade do |t|
|
||||||
t.text "text", null: false
|
t.text "text", limit: 65535, null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "quantities", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t|
|
create_table "quantities", force: :cascade do |t|
|
||||||
t.bigint "user_id"
|
t.integer "user_id"
|
||||||
t.string "name", limit: 31, null: false
|
t.string "name", limit: 31, null: false
|
||||||
t.text "description"
|
t.text "description", limit: 65535
|
||||||
t.bigint "parent_id"
|
t.integer "parent_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "depth", default: 0, 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"
|
t.index ["user_id"], name: "index_quantities_on_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "readouts", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t|
|
create_table "readouts", force: :cascade do |t|
|
||||||
t.bigint "user_id", null: false
|
t.integer "user_id", null: false
|
||||||
t.bigint "measurement_id"
|
t.integer "measurement_id"
|
||||||
t.bigint "quantity_id", null: false
|
t.integer "quantity_id", null: false
|
||||||
t.integer "category", default: 0, null: false
|
t.integer "category", default: 0, null: false
|
||||||
t.float "value", limit: 53, 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 "created_at", null: false
|
||||||
t.datetime "updated_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", "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 ["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 ["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 ["unit_id"], name: "index_readouts_on_unit_id"
|
||||||
t.index ["user_id"], name: "index_readouts_on_user_id"
|
t.index ["user_id"], name: "index_readouts_on_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "units", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t|
|
create_table "units", force: :cascade do |t|
|
||||||
t.bigint "user_id"
|
t.integer "user_id"
|
||||||
t.string "symbol", limit: 15, null: false
|
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.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 "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.index ["base_id"], name: "index_units_on_base_id"
|
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"
|
t.index ["user_id"], name: "index_units_on_user_id"
|
||||||
end
|
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.string "email", limit: 64, null: false
|
||||||
t.integer "status", default: 0, null: false
|
t.integer "status", default: 0, null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
||||||
@@ -7,13 +7,4 @@ module CoreExt::Arel::Visitors::ToSql
|
|||||||
|
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def visit_Arel_Nodes_UpdateStatement(o, collector)
|
|
||||||
if o.with
|
|
||||||
collector = visit o.with, collector
|
|
||||||
collector << " "
|
|
||||||
end
|
|
||||||
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ class DefaultSettingsStrategy < ActiveRecord::Migration::DefaultStrategy
|
|||||||
COLUMN_DEFAULTS = {
|
COLUMN_DEFAULTS = {
|
||||||
# TODO: all types `null: false` ?
|
# TODO: all types `null: false` ?
|
||||||
# TODO: references `foreign_key: {on_delete: :cascade}` ?
|
# 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
|
# `limit:` for `text` - `text` can be theoretically up to 1GB or
|
||||||
# longer, so roughly unlimited for practical purposes. But:
|
# longer, so roughly unlimited for practical purposes. But:
|
||||||
# * the actual usable length depends on additional factors, like compile
|
# * the actual usable length depends on additional factors, like compile
|
||||||
# time limits (`SQLITE_MAX_LENGTH` in SQLite), runtime settings
|
# time limits (`SQLITE_MAX_LENGTH` in SQLite) and probably other,
|
||||||
# (`max_allowed_packet` in MySQL) and probably other,
|
|
||||||
# * Rails does not report limit for `text` column types, unless it is
|
# * Rails does not report limit for `text` column types, unless it is
|
||||||
# explicitly set.
|
# explicitly set.
|
||||||
# The decision is to always set safe limit and enforce it by validations, to
|
# The decision is to always set safe limit and enforce it by validations, to
|
||||||
@@ -24,20 +24,20 @@ class DefaultSettingsStrategy < ActiveRecord::Migration::DefaultStrategy
|
|||||||
end
|
end
|
||||||
ActiveRecord::ConnectionAdapters::TableDefinition.prepend ColumnSettingsStrategy
|
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
|
# `if_not_exists: true`/`if_exists: true` - without these options it's impossible
|
||||||
# to change migration status once migration fails partially. If `up` migration
|
# 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
|
# 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`
|
# `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 = {
|
MIGRATION_DEFAULTS = {
|
||||||
add_check_constraint: {if_not_exists: true},
|
add_check_constraint: {if_not_exists: true},
|
||||||
add_column: {if_not_exists: true},
|
add_column: {if_not_exists: true},
|
||||||
add_foreign_key: {if_not_exists: true},
|
add_foreign_key: {if_not_exists: true},
|
||||||
add_index: {if_not_exists: true, unique: true},
|
add_index: {if_not_exists: true, unique: true},
|
||||||
add_timestamps: {if_not_exists: true},
|
add_timestamps: {if_not_exists: true},
|
||||||
create_table: {if_not_exists: true},
|
create_join_table: {force: :cascade},
|
||||||
drop_table: {if_exists: true},
|
create_table: {force: :cascade},
|
||||||
|
drop_table: {force: :cascade},
|
||||||
remove_check_constraint: {if_exists: true},
|
remove_check_constraint: {if_exists: true},
|
||||||
remove_column: {if_exists: true},
|
remove_column: {if_exists: true},
|
||||||
remove_foreign_key: {if_exists: true},
|
remove_foreign_key: {if_exists: true},
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ require "test_helper"
|
|||||||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||||
include ActionView::Helpers::UrlHelper
|
include ActionView::Helpers::UrlHelper
|
||||||
|
|
||||||
# NOTE: geckodriver installed with Firefox, ignore incompatibility warning
|
# `geckodriver` installed with Firefox, ignore incompatibility warning.
|
||||||
Selenium::WebDriver.logger
|
Selenium::WebDriver.logger
|
||||||
.ignore(:selenium_manager, :clear_session_storage, :clear_local_storage)
|
.ignore(:selenium_manager, :clear_session_storage, :clear_local_storage)
|
||||||
|
|
||||||
@@ -33,33 +33,24 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
|||||||
button.html_safe)
|
button.html_safe)
|
||||||
end
|
end
|
||||||
|
|
||||||
DB_CONFIGS = ActiveRecord::Base.configurations.configs_for(env_name: "test")
|
#DB_CONFIGS = ActiveRecord::Base.configurations.configs_for(env_name: "test")
|
||||||
TEST_CONFIGS = Hash.new(DB_CONFIGS.first.name.to_sym)
|
#TEST_CONFIGS = Hash.new(DB_CONFIGS.first.name.to_sym)
|
||||||
class << self
|
#class << self
|
||||||
# NOTE: alternative to current solution is to create shards:
|
# # Test block should not be modified here, as it would change its binding from
|
||||||
# ActiveRecord::Base.connects_to(
|
# # instance level to class level.
|
||||||
# shards: {mysql2: {writing: :mysql2}, sqlite3: {writing: :sqlite3}}
|
# # TODO: allow multiple iterations of tests? would require saving seed in
|
||||||
# )
|
# # #setup to make reproducing easier
|
||||||
# and use them in one of the following ways:
|
# if DB_CONFIGS.many?
|
||||||
# * set config.active_record.shard_selector/shard_resolver
|
# def test(name, ...)
|
||||||
# * run tests within: ActiveRecord::Base.connected_to(shard: :sqlite3) { test_ }
|
# DB_CONFIGS.each do |config|
|
||||||
# Remove this note once current solution is confirmed to work.
|
# TEST_CONFIGS[super("#{config.name} #{name}", ...)] = config.name.to_sym
|
||||||
#
|
# end
|
||||||
# Test block should not be modified here, as it would change its binding from
|
# end
|
||||||
# instance level to class level.
|
# end
|
||||||
# TODO: allow multiple iterations of tests? would require saving seed in
|
#end
|
||||||
# #setup to make reproducing easier
|
#setup do
|
||||||
if DB_CONFIGS.many?
|
# ActiveRecord::Base.establish_connection(TEST_CONFIGS[name.to_sym])
|
||||||
def test(name, ...)
|
#end
|
||||||
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
|
Capybara.modify_selector(:link) do
|
||||||
expression_filter(:disabled) do |xpath, value|
|
expression_filter(:disabled) do |xpath, value|
|
||||||
|
|||||||
Reference in New Issue
Block a user