Class: GitFit::DB::CLI
- Inherits:
-
Thor
- Object
- Thor
- GitFit::DB::CLI
- Defined in:
- lib/git_fit/db/cli.rb
Instance Method Summary collapse
Instance Method Details
#migrate ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/git_fit/db/cli.rb', line 7 def migrate config = GitFit::Config.new conn = GitFit::DB::Connection.new(config.db_path) conn.migrate! say_status :done, "Migrations up to date", :green rescue => e say_status :error, "Migration failed: #{e.}", :red end |
#schema ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/git_fit/db/cli.rb', line 18 def schema require "digest" db = Sequel.sqlite Sequel.extension :migration dir = File.("../../../db/migrations", __dir__) Sequel::Migrator.run(db, dir) ddl = db.fetch("SELECT sql FROM sqlite_master WHERE sql IS NOT NULL ORDER BY name") .map(:sql).join("\n") + "\n" if [:hash] puts Digest::SHA256.hexdigest(ddl) else print ddl end end |