Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. require 'sequel'
  2. require_relative 'service'
  3.  
  4. class DatabaseRecorder < Service
  5. def initialize(deploy_event)
  6. super(deploy_event)
  7. @database_url = ENV.fetch('DATABASE_URL', nil)
  8. end
  9.  
  10. def current_time
  11. Time.now
  12. end
  13.  
  14. def call
  15. Sequel.connect(@database_url) do |db|
  16. unless
  17. db.table_exists?(:graf);
  18. db.create_table(:graf) do
  19. primary_key :id
  20. String :when
  21. String :app
  22. String :env
  23. String :who
  24. String :branch
  25. String :sha
  26. end
  27. 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);
  28. end
  29. end
  30. end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement