Sha256: a1ee2168261e9d2318eabade9e6e3a87bf30a56d177e26127be8fa92eedc6299

Contents?: true

Size: 608 Bytes

Versions: 5

Compression:

Stored size: 608 Bytes

Contents

namespace :db do
  namespace :triggers do
    desc "Creates a new database migration representing changes in model-defined triggers"
    task migration: :environment do
      if ActiveRecord::Base.connection.migration_context.needs_migration?
        puts "Abort: some migrations are pending"
        exit(1)
      end

      require "pg_trigger/generator"

      Rails.application.eager_load!
      filename = PgTrigger::Generator.run(models: ActiveRecord::Base.descendants)

      if filename
        puts "Generated #{filename}"
      else
        puts "Everything up-to-date"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails-pg_trigger-0.1.4 lib/tasks/pg_trigger.rake
rails-pg_trigger-0.1.3 lib/tasks/pg_trigger.rake
rails-pg_trigger-0.1.2 lib/tasks/pg_trigger.rake
rails-pg_trigger-0.1.1 lib/tasks/pg_trigger.rake
rails-pg_trigger-0.1.0 lib/tasks/pg_trigger.rake