module DataMapper::Migrations::PostgresAdapter::SQL
Public Instance Methods
property_schema_statement(connection, schema)
click to toggle source
# File lib/dm-pg-json.rb, line 14 def property_schema_statement(connection, schema) statement = quote_name(schema[:name]) statement << " #{schema[:primitive]}" length = schema[:length] if schema[:precision] && schema[:scale] statement << "(#{[ :precision, :scale ].map { |key| connection.quote_value(schema[key]) }.join(', ')})" elsif length == 'max' statement << '(max)' elsif length statement << "(#{connection.quote_value(length)})" end default = schema[:default] if default if schema[:primitive] == 'JSON' stmt = " DEFAULT #{connection.quote_value(default)}::JSON" else stmt = " DEFAULT #{connection.quote_value(default)}" end statement << stmt end statement << ' NOT NULL' unless schema[:allow_nil] statement end