Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxemitchell committed Nov 14, 2024
1 parent f0bd4fd commit 6c2d4ae
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gem "dry-system", github: "dry-rb/dry-system", branch: "main"

gem "rack"

# gem "mysql2"
gem "mysql2"
gem "pg"
gem "sqlite3"

Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/cli/commands/app/db/migrate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Migrate < DB::Command
option :gateway, required: false, desc: "Use database for gateway"
option :target, desc: "Target migration number", aliases: ["-t"]
option :dump, required: false, type: :boolean, default: true,
desc: "Dump the database structure after migrating"
desc: "Dump the database structure after migrating"

def call(target: nil, app: false, slice: nil, gateway: nil, dump: true, command_exit: method(:exit), **)
databases(app: app, slice: slice, gateway: gateway).each do |database|
Expand Down
3 changes: 2 additions & 1 deletion lib/hanami/cli/commands/app/db/utils/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ def schema_migrations_sql_dump
migrations_sql = super
return unless migrations_sql


search_path = gateway.connection
.fetch("SHOW search_path").to_a.first
.fetch(:search_path)

"SET search_path TO #{search_path};\n\n" << migrations_sql
+"SET search_path TO #{search_path};\n\n" << migrations_sql
end

private
Expand Down
14 changes: 8 additions & 6 deletions lib/hanami/cli/commands/app/db/utils/sqlite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def exec_create_command
def exec_drop_command
begin
File.unlink(file_path) if exists?
rescue StandardError => e
rescue => e
# Mimic a system_call result
return Failure.new(e.message)
end
Expand Down Expand Up @@ -76,11 +76,13 @@ def name
private

def file_path
@file_path ||= if File.absolute_path?(name)
name
else
slice.app.root.join(name).to_s
end
@file_path ||= begin
if File.absolute_path?(name)
name
else
slice.app.root.join(name).to_s
end
end
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/hanami/cli/commands/app/generate/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def call(
raise InvalidActionNameError.new(name)
end

generator.call(app.namespace, controller, action, url, http, format, skip_view, skip_route, slice,
context: context)
generator.call(app.namespace, controller, action, url, http, format, skip_view, skip_route, slice, context: context)
end

# rubocop:enable Metrics/ParameterLists
Expand Down
16 changes: 8 additions & 8 deletions lib/hanami/cli/commands/app/generate/slice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ class Slice < App::Command
# @since 2.2.0
# @api private
option :skip_db,
type: :flag,
required: false,
default: SKIP_DB_DEFAULT,
desc: "Skip database"
type: :flag,
required: false,
default: SKIP_DB_DEFAULT,
desc: "Skip database"
# @since 2.2.0
# @api private
option :skip_route,
type: :flag,
required: false,
default: DEFAULT_SKIP_ROUTE,
desc: "Skip route generation"
type: :flag,
required: false,
default: DEFAULT_SKIP_ROUTE,
desc: "Skip route generation"

example [
"admin # Admin slice (/admin URL prefix)",
Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/cli/commands/app/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Install < Command
def initialize(
fs:,
bundler: CLI::Bundler.new(fs: fs),
**_opts
**opts
)
@bundler = bundler
end
Expand Down
4 changes: 2 additions & 2 deletions lib/hanami/cli/commands/gem/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def initialize(
@system_call = system_call
end

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity

# @since 2.0.0
# @api private
Expand Down Expand Up @@ -162,7 +162,7 @@ def call(
end
end
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity

private

Expand Down
10 changes: 5 additions & 5 deletions spec/unit/hanami/cli/commands/app/db/prepare_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class Comments < Hanami::DB::Relation
expect(output).to include_in_order(
"database #{POSTGRES_BASE_DB_NAME}_app created",
"database #{POSTGRES_BASE_DB_NAME}_app migrated",
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
"seed data loaded from config/db/seeds.rb",
)
expect(output).not_to include "#{POSTGRES_BASE_DB_NAME}_main"
Expand All @@ -310,7 +310,7 @@ class Comments < Hanami::DB::Relation
expect(output).to include_in_order(
"database #{POSTGRES_BASE_DB_NAME}_main created",
"database #{POSTGRES_BASE_DB_NAME}_main migrated",
"#{POSTGRES_BASE_DB_NAME}_main structure dumped to slices/main/config/db/structure.sql",
"#{POSTGRES_BASE_DB_NAME}_main structure dumped to slices/main/config/db/structure.sql",
"seed data loaded from slices/main/config/db/seeds.rb"
)
expect(output).not_to include "#{POSTGRES_BASE_DB_NAME}_app"
Expand Down Expand Up @@ -349,7 +349,7 @@ class Comments < Hanami::DB::Relation
expect(output).to include_in_order(
"database #{POSTGRES_BASE_DB_NAME}_app created",
"database #{POSTGRES_BASE_DB_NAME}_app migrated",
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
"seed data loaded from config/db/seeds.rb",
)
end
Expand Down Expand Up @@ -377,7 +377,7 @@ class Comments < Hanami::DB::Relation
expect(output).to include_in_order(
"database #{POSTGRES_BASE_DB_NAME}_app created", # TODO: it would be good not to include this
"database #{POSTGRES_BASE_DB_NAME}_app migrated",
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
"seed data loaded from config/db/seeds.rb",
)
end
Expand Down Expand Up @@ -405,7 +405,7 @@ class Comments < Hanami::DB::Relation
expect(output).to include_in_order(
"database #{POSTGRES_BASE_DB_NAME}_app created", # TODO: it would be good not to include this
"database #{POSTGRES_BASE_DB_NAME}_app migrated",
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql"
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql"
)
expect(output).not_to include "seed data loaded from config/db/seeds.rb"
end
Expand Down

0 comments on commit 6c2d4ae

Please sign in to comment.