Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'sequel'
- require_relative 'service'
- class DatabaseRecorder < Service
- def initialize(deploy_event)
- super(deploy_event)
- @database_url = ENV.fetch('DATABASE_URL', nil)
- end
- def current_time
- Time.now
- end
- def call
- Sequel.connect(@database_url) do |db|
- unless
- db.table_exists?(:graf);
- db.create_table(:graf) do
- primary_key :id
- String :when
- String :app
- String :env
- String :who
- String :branch
- String :sha
- end
- db[:graf].insert(when: #{current_time} app: @deploy_event.application, env: @deploy_event.environment, who: @deploy_event.deployer, branch: @deploy_event.branch, sha: @deploy_event.revision);
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement