Skip to content

Commit 64f683f

Browse files
committed
add create table command
1 parent dee4409 commit 64f683f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/db/load_helper.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
module LoadHelper
55
def self.import_on_local()
6+
LoadHelper.create_db_if_not_exists fetch(:db_name)
7+
68
run_locally do
79
execute "mysql #{Helper::mysql_restore_args} < #{fetch(:db_local_dump)}"
810
end
@@ -11,12 +13,20 @@ def self.import_on_local()
1113
def self.import_on_container(container)
1214
container.upload!(fetch(:db_local_dump), fetch(:db_remote_dump))
1315

16+
LoadHelper.create_db_if_not_exists fetch(:db_name)
17+
1418
container.execute "mysql #{Helper::mysql_restore_args} < #{fetch(:db_remote_dump)}"
1519
end
1620

1721
def self.import_on_server()
1822
upload!(fetch(:db_local_dump), fetch(:db_remote_dump))
1923

24+
LoadHelper.create_db_if_not_exists fetch(:db_name)
25+
2026
execute("mysql #{Helper::mysql_restore_args} < #{fetch(:db_remote_dump)}")
2127
end
28+
29+
def self.create_db_if_not_exists(db)
30+
Helper.execute_db_command_autodetect "CREATE DATABASE IF NOT EXISTS #{db};"
31+
end
2232
end

0 commit comments

Comments
 (0)