LoginSignup
0
0

More than 3 years have passed since last update.

マイグレーションツール作ってみた

Last updated at Posted at 2019-07-04

マイグレーションツールはgooseのシンプルさが気に入っていたのですが、多少使いづらい点があったため、ほぼ同じ機能にして自分で気に入るものを作ってみました

  • コマンドも大体一緒 up / down / status
  • MySQLとPostgresしかサポートしてません

mg
https://github.com/nissy/mg

こんな感じの設定ファイルです

[postgres-sample]
  driver = "postgres"
  dsn = "postgres://user:${PASSWORD}@${HOSTNAME}:5432/dbname?sslmode=disable"
  source_dir = [
    "./data/postgres/migrates",
    "./data/postgres/seeds"
  ]

ポイント

  • SQLのsourceディレクトリを複数選べる
    これがつくりたかった動機なんですが、環境によって差し込みたいとかあるので、複数ディレクトリ選べてファイルを時系列順に入れたかった

  • 設定ファイルに環境変数使える
    使いたかった
    ${PASSWORD} こんな感じで使える

感想

今の会社で採用してもらえたので嬉しい

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0