diff --git a/lib/storey/gen_dump_command.rb b/lib/storey/gen_dump_command.rb
index <HASH>..<HASH> 100644
--- a/lib/storey/gen_dump_command.rb
+++ b/lib/storey/gen_dump_command.rb
@@ -43,8 +43,8 @@ module Storey
       command_parts += [
         Utils.command_line_switches_from(switches),
         schemas_switches,
-        database,
       ]
+      command_parts << database if database_url.blank?
       command_parts.compact.join(' ')
     end
 
diff --git a/spec/storey/gen_dump_command_spec.rb b/spec/storey/gen_dump_command_spec.rb
index <HASH>..<HASH> 100644
--- a/spec/storey/gen_dump_command_spec.rb
+++ b/spec/storey/gen_dump_command_spec.rb
@@ -31,6 +31,21 @@ module Storey
       end
     end
 
+    context "connection string is passed in" do
+      let(:options) do
+        {
+          structure_only: true,
+          file: 'myfile.sql',
+          database_url: "postgres://user:pass@ip.com:5432/db",
+          database: "testdb",
+        }
+      end
+
+      it "ignores the `database` value" do
+        expect(command).to_not match /testdb/
+      end
+    end
+
     context "connection string is set in Storey" do
       before do
         Storey.configuration.database_url = "postgres://user:pass@ip.com:5432/db"
GenDumpCommand does not insert database if connection string is given