Invert the conditionals to make easier to read

Also improve some of the code conventions
上级 fb522a27
......@@ -186,10 +186,10 @@ def column_exists?(table_name, column_name, type = nil, options = {})
def create_table(table_name, options = {})
td = create_table_definition table_name, options[:temporary], options[:options], options[:as]
unless options[:id] == false || options[:as]
pk = options.fetch(:primary_key) {
if options[:id] != false && !options[:as]
pk = options.fetch(:primary_key) do
Base.get_primary_key table_name.to_s.singularize
}
end
td.primary_key pk, options.fetch(:id, :primary_key), options
end
......@@ -201,7 +201,7 @@ def create_table(table_name, options = {})
end
result = execute schema_creation.accept td
td.indexes.each_pair { |c,o| add_index table_name, c, o } unless supports_indexes_in_create?
td.indexes.each_pair { |c, o| add_index(table_name, c, o) } unless supports_indexes_in_create?
result
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册