Skip to content

Commit

Permalink
Make database.yml actually use all the db engines on CI (#27)
Browse files Browse the repository at this point in the history
* Make database.yml actually use all the db engines on CI

* Fix mysql database name

* Remove default value from properties

* Fix rubocop

* Fix rubocop
  • Loading branch information
mbajur authored Dec 18, 2024
1 parent 757914a commit 3538864
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
image: mysql:8.0
env:
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: inner_performance_gem_test
MYSQL_DATABASE: inner_performance_test
MYSQL_USER: inner_performance
MYSQL_PASSWORD: inner_performance
MYSQL_ROOT_PASSWORD: inner_performance
Expand Down
10 changes: 10 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@ inherit_from: .rubocop_todo.yml

inherit_gem:
rubocop-shopify: rubocop.yml

Style/FrozenStringLiteralComment:
Exclude:
- 'spec/dummy/db/schema.rb'
- 'db/migrate/*'

Style/MethodCallWithArgsParentheses:
Exclude:
- 'spec/dummy/db/schema.rb'

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveDefaultValueFromInnerPerformanceEventsProperties < ActiveRecord::Migration[8.0]
def change
change_column_default(:inner_performance_events, :properties, nil)
end
end
50 changes: 31 additions & 19 deletions spec/dummy/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem "sqlite3"
#
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
<%
db_adapter = ENV.fetch('DB', 'sqlite3')
db_host = ENV.fetch('DB_HOST', ENV.fetch('DB_1_PORT_5432_TCP_ADDR', 'localhost'))
db_port = ENV['DB_1_PORT_5432_TCP_PORT'] || ENV['DB_PORT'] ||
{'postgresql' => 5432, 'mysql2' => 3306}[db_adapter]
require 'etc'
db_pool_size = ENV['DB_POOL'] || (
# Web: max workers * max threads
ENV.fetch('WEB_CONCURRENCY', 3).to_i * ENV.fetch('MAX_THREADS', 5).to_i +
# ActiveJob Async max thread pool size
Etc.nprocessors
)
%>

defaults: &defaults
host: <%= db_host %>
port: <%= db_port %>
adapter: <%= db_adapter %>
min_messages: WARNING
pool: <%= db_pool_size %>
username: <%= ENV.fetch('DB_USERNAME', 'inner_performance').inspect %>
password: <%= ENV.fetch('DB_PASSWORD', 'inner_performance').inspect %>

development:
<<: *default
database: storage/development.sqlite3
<<: *defaults
database: <%= db_adapter == 'sqlite3' ? ENV.fetch('DATABASE_FILE', 'db/development.sqlite3') : 'inner_performance_dev' %>

# Warning: The database 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:
<<: *default
database: storage/test.sqlite3
<<: *defaults
database: <%= db_adapter == 'sqlite3' ? ENV.fetch('DATABASE_FILE', 'db/test.sqlite3') : 'inner_performance_test' %>

production:
<<: *default
database: storage/production.sqlite3
<<: *defaults
encoding: utf8
min_messages: WARNING
url: <%= ENV['DATABASE_URL'].inspect if ENV['DATABASE_URL'] %>
database: <%= (db_adapter == 'sqlite3' ? 'db/production.sqlite3' : 'inner_performance_production') unless ENV['DATABASE_URL'] %>
20 changes: 9 additions & 11 deletions spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# 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.
Expand All @@ -12,15 +10,15 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 20_241_124_111_458) do
ActiveRecord::Schema[7.1].define(version: 2024_12_18_082041) do
create_table "inner_performance_events", force: :cascade do |t|
t.string("event")
t.string("name")
t.decimal("duration")
t.decimal("db_runtime")
t.datetime("created_at", null: false)
t.datetime("updated_at", null: false)
t.text("properties", default: "{}")
t.string("type")
t.string "event"
t.string "name"
t.decimal "duration"
t.decimal "db_runtime"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "properties"
t.string "type"
end
end

0 comments on commit 3538864

Please sign in to comment.