Add Command#require_models!
This commit is contained in:
parent
dc0093c7d9
commit
c1b3498e99
5 changed files with 10 additions and 4 deletions
|
@ -16,4 +16,10 @@ class Twenty::Command < Cmd
|
||||||
require_relative "command/disconnect"
|
require_relative "command/disconnect"
|
||||||
require_relative "command/migrate"
|
require_relative "command/migrate"
|
||||||
require_relative "command/console"
|
require_relative "command/console"
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def require_models!
|
||||||
|
require "twenty/server/model"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,9 +21,9 @@ class Twenty::Command::Connect < Twenty::Command
|
||||||
private
|
private
|
||||||
|
|
||||||
def run_command(options)
|
def run_command(options)
|
||||||
require "twenty/server/model"
|
|
||||||
path = File.realpath(options.path ? options.path : Dir.getwd)
|
path = File.realpath(options.path ? options.path : Dir.getwd)
|
||||||
if File.exist?(path)
|
if File.exist?(path)
|
||||||
|
require_models!
|
||||||
project = Twenty::Project.create(
|
project = Twenty::Project.create(
|
||||||
name: File.basename(path),
|
name: File.basename(path),
|
||||||
path:
|
path:
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Twenty::Command::Console < Twenty::Command
|
||||||
private
|
private
|
||||||
|
|
||||||
def run_command(options)
|
def run_command(options)
|
||||||
require "twenty/server/model"
|
require_models!
|
||||||
require "irb"
|
require "irb"
|
||||||
TOPLEVEL_BINDING.irb
|
TOPLEVEL_BINDING.irb
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,8 +19,8 @@ class Twenty::Command::Disconnect < Twenty::Command
|
||||||
private
|
private
|
||||||
|
|
||||||
def run_command(options)
|
def run_command(options)
|
||||||
require "twenty/server/model"
|
|
||||||
path = File.realpath(options.path ? options.path : Dir.getwd)
|
path = File.realpath(options.path ? options.path : Dir.getwd)
|
||||||
|
require_models!
|
||||||
Twenty::Project
|
Twenty::Project
|
||||||
.where(path:)
|
.where(path:)
|
||||||
.first!
|
.first!
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Twenty::Command::Up < Twenty::Command
|
||||||
private
|
private
|
||||||
|
|
||||||
def run_command(options)
|
def run_command(options)
|
||||||
require "twenty/server/model"
|
require_models!
|
||||||
File.binwrite(pid, Process.pid.to_s)
|
File.binwrite(pid, Process.pid.to_s)
|
||||||
thr = Twenty::Rack.server(options).start
|
thr = Twenty::Rack.server(options).start
|
||||||
thr.join
|
thr.join
|
||||||
|
|
Loading…
Reference in a new issue