From a85ca250ce85f6b0b135ab69faf0d2ea73a48daf Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sun, 14 Jan 2024 22:08:02 +1100 Subject: [PATCH] update config --- .github/workflows/master.yml | 6 +++++- {spec/config => config}/database.yml | 0 spec/spec_helper.rb | 19 +++++++++++-------- spec/tasks/database.rake | 15 ++++++--------- 4 files changed, 22 insertions(+), 18 deletions(-) rename {spec/config => config}/database.yml (100%) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 8ba1a83e..91589d33 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -35,6 +35,10 @@ jobs: run: | sudo apt-get -qq install -y postgresql-client export PGPASSWORD=outboxer_password - psql -h localhost -U outboxer_tester -d outboxer_test -c 'SELECT version();' + psql -h localhost -U outboxer_tester -d outboxer_test -c 'SELECT version(); + # - name: Create Database + # run: RAILS_ENV=test bin/rake outboxer:db:create -f spec/tasks/database.rake + - name: Run Database Migrations + run: RAILS_ENV=test bin/rake outboxer:db:migrate -f spec/tasks/database.rake - name: Run the default task run: bundle exec rake diff --git a/spec/config/database.yml b/config/database.yml similarity index 100% rename from spec/config/database.yml rename to config/database.yml diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e8dbbccb..8ebca316 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,14 +22,17 @@ # 'database' => 'outboxer_test' # } - db_config = { - 'adapter' => 'postgresql', - 'username' => 'outboxer_tester', - 'password' => 'outboxer_password', - 'database' => 'outboxer_test', - 'host' => 'localhost', - 'port' => 5432 - } + # db_config = { + # 'adapter' => 'postgresql', + # 'username' => 'outboxer_tester', + # 'password' => 'outboxer_password', + # 'database' => 'outboxer_test', + # 'host' => 'localhost', + # 'port' => 5432 + # } + + db_config_path = File.expand_path('config/database.yml', Dir.pwd) + db_config = YAML.load_file(db_config_path)[env] Outboxer::Publisher.connect!(db_config: db_config) diff --git a/spec/tasks/database.rake b/spec/tasks/database.rake index 15e72748..0bf35972 100644 --- a/spec/tasks/database.rake +++ b/spec/tasks/database.rake @@ -9,9 +9,6 @@ namespace :outboxer do ActiveRecord::Base.establish_connection({ 'adapter' => 'postgresql', 'username' => `whoami`.strip, 'database' => 'postgres' }) - db_config_path = File.expand_path('../config/database.yml', __dir__) - db_config = YAML.load_file(db_config_path)[ENV.fetch('RAILS_ENV')] - ActiveRecord::Base.connection.drop_database(db_config['database']) ActiveRecord::Base.connection.disconnect! @@ -21,7 +18,7 @@ namespace :outboxer do ActiveRecord::Base.establish_connection({ 'adapter' => 'postgresql', 'username' => `whoami`.strip, 'database' => 'postgres' }) - db_config_path = File.expand_path('../config/database.yml', __dir__) + db_config_path = File.expand_path('config/database.yml', Dir.pwd) db_config = YAML.load_file(db_config_path)[ENV.fetch('RAILS_ENV')] ActiveRecord::Base.connection.create_database(db_config['database']) @@ -30,7 +27,7 @@ namespace :outboxer do end task :migrate do - db_config_path = File.expand_path('../config/database.yml', __dir__) + db_config_path = File.expand_path('config/database.yml', Dir.pwd) db_config = YAML.load_file(db_config_path)[ENV.fetch('RAILS_ENV')] ActiveRecord::Base.establish_connection(db_config) @@ -40,11 +37,11 @@ namespace :outboxer do require_relative "../../generators/outboxer/templates/migrations/create_outboxer_exceptions" CreateOutboxerExceptions.new.up - require_relative "../db/migrate/create_accounting_invoices" - CreateAccountingInvoices.new.up + # require_relative "../db/migrate/create_accounting_invoices" + # CreateAccountingInvoices.new.up - require_relative "../db/migrate/create_events" - CreateEvents.new.up + # require_relative "../db/migrate/create_events" + # CreateEvents.new.up ActiveRecord::Base.connection.disconnect! end