You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Rakefile 663B

  1. # frozen_string_literal: true
  2. require "dotenv/load"
  3. require "bundler/setup"
  4. require "active_record"
  5. require "pg"
  6. require "logger"
  7. require "sinatra"
  8. require "sinatra/reloader" if development?
  9. ActiveRecord::Base.logger = Logger.new("debug.log")
  10. ActiveRecord::Base.establish_connection(ENV.fetch("DATABASE_URL"))
  11. task default: :migrate
  12. def schema_migrations
  13. ActiveRecord::SchemaMigration.tap(&:create_table)
  14. end
  15. def migration_context
  16. ActiveRecord::MigrationContext.new("db/migrate", schema_migrations)
  17. end
  18. desc "Run migrations"
  19. task :migrate do
  20. migration_context.migrate
  21. end
  22. desc "Rollback migrations"
  23. task :rollback do
  24. migration_context.rollback
  25. end