Sha256: 1d0ac260a66d28ea8f7062e311f554627df7683bde8eafb2388cca056f2825ce

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 Bytes

Contents

require "migrations_watchdog/version"

module MigrationsWatchdog
  class Error < StandardError
  end

  def self.check(paths)
    migration_files = []
    others = []

    paths.each do |file|
      if file.match('\Adb/structure.sql') || file.match('\Adb/migrate')
        migration_files.push(file)
      elsif file.match('.*\.rb')
        # We could do a short circuit here but let's collect all files for
        # better error message
        others.push(file)
      end
    end

    if migration_files.size > 0 && others.size > 0
      raise Error.new("Migrations and app code detected. Move out the following files:\n#{others.join('\b')}")
    end

    true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
migrations_watchdog-0.1.0 lib/migrations_watchdog.rb