Sha256: 4173c7f0ab18d8ee91510131e27eedcda2a6074069c2c0fd16a06fa736a34b5a

Contents?: true

Size: 846 Bytes

Versions: 2

Compression:

Stored size: 846 Bytes

Contents

require "prick/state.rb"

module Prick
  PRICK_SCHEMA = "prick"
  SCHEMA_NAMES = %w(schema roles types tables data constraints indexes views functions comments grants)
  BUILD_BASE_NAME = "build"
  BUILD_SQL_FILE = BUILD_BASE_NAME + ".sql"
  BUILD_YML_FILE = BUILD_BASE_NAME + ".yml"

  # Note this models the SCHEMAS_DIR directory, not a database schema
  class Schema
    def yml_file() SchemaBuilder.yml_file(SCHEMA_DIR) end

    def version() SchemaVersion.load end
    def version=(version) SchemaVersion.new(version).write end
    def version_file() SchemaVersion.new.path end

    def built?(database) database.exist? && database.version == version end

    # `subject` can be a subpath of schema/ (ie. 'public/tables')
    def build(database, subject = nil)
      SchemaBuilder.new(database, SCHEMA_DIR).build(subject)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prick-0.6.0 lib/prick/schema.rb
prick-0.5.0 lib/prick/schema.rb