lib/ridgepole/dsl_parser/context.rb in ridgepole-1.1.0 vs lib/ridgepole/dsl_parser/context.rb in ridgepole-1.2.0

- old
+ new

@@ -89,9 +89,24 @@ to_table: to_table, options: options, } end + def add_check_constraint(table_name, expression, options = {}) + table_name = table_name.to_s + expression = expression.to_s + options[:name] = options[:name].to_s if options[:name] + + idx = options[:name] || expression + + @__definition[table_name] ||= {} + @__definition[table_name][:check_constraints] ||= {} + @__definition[table_name][:check_constraints][idx] = { + expression: expression, + options: options, + } + end + def require(file) schemafile = %r{\A/}.match?(file) ? file : File.join(@__working_dir, file) if File.exist?(schemafile) instance_eval(File.read(schemafile), schemafile)