Class: Migrate::Lang::Go
- Inherits:
-
Migrate::Lang
- Object
- Migrate::Lang
- Migrate::Lang::Go
- Defined in:
- lib/migrate/lang/go.rb
Instance Method Summary collapse
- #create_migration(dir) ⇒ Object
- #exec_migration(dir, is_up) ⇒ Object
-
#initialize ⇒ Go
constructor
A new instance of Go.
Constructor Details
#initialize ⇒ Go
Returns a new instance of Go.
4 5 6 |
# File 'lib/migrate/lang/go.rb', line 4 def initialize @ext = "go" end |
Instance Method Details
#create_migration(dir) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/migrate/lang/go.rb', line 8 def create_migration(dir) File.open("#{dir}/up.#{@ext}", "w") do |f| f.puts "package main\n\nfunc main() {\n // Here goes your Go migration forward\n}\n eot\n end\n\n File.open(\"\#{dir}/down.\#{@ext}\", \"w\") do |f|\n f.puts <<-eot\npackage main\n\nfunc main() {\n // Here goes your Go migration backward\n}\n eot\n end\nend\n" |
#exec_migration(dir, is_up) ⇒ Object
30 31 32 33 34 |
# File 'lib/migrate/lang/go.rb', line 30 def exec_migration(dir, is_up) script = "#{dir}/#{is_up ? "up" : "down"}.#{@ext}" Log.info("Executing #{script}...") `go run #{script}` end |