Skip to content

Talos208/chabashira

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chabashira

Simple bridge tool between genmai and ridgepole.

Dependency

Installlation

go install github.com/Talos208/chabashira

Schema

It's based on schema description of genmai.

// It isn't target.
type Hoge struct {
  ...
}

// It is target.
// db:"entity"
type Fuga struct {
  Id int64 `db:"pk"`       // Primary Key
  A  sql.NullInt64         // Nullable integer
  B  string `db:"unique"`  // varchar with Unique constraint
  C  string `limit:"30"`   // varchar(30)
  D  float `default:"1.0"` // Real with default value
  E  []byte                // Binary
  F  time.Time             // timestamp
  PiyoId int64 `refer:""`  // Reference to table "Piyo"
}

// It is target too.
// db:"entity"
type Piyo struct {
  Id int64 `db:"pk"`
  ...
}

Usage

chabashira <directory or file>

If specify file, process it. If specify path, process all .go files in sepcified directory. Chabashira collect schema information from struct which hava db:"entity" in it's comment. Then generates Rails's migration format file. Like this.

create_table 'fuga' do |t|
  t.integer :a
  t.string :b, unique:true, null:false
  t.string :c, null:false
  t.float :d, null:false
  t.binary :e
  t.timestamp :f, null:false
  t.references :piyo
end

create_table 'piyo' do |t|
  ...
end

About

Simple bridge tool between genmai and ridgepole.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages