File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
lib/active_record/connection_adapters/sqlserver Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ def create_database(database, options = {})
88 name = SQLServer ::Utils . extract_identifiers ( database )
99 db_options = create_database_options ( options )
1010 edition_options = create_database_edition_options ( options )
11+ compatibility_options = create_database_compatibility_options ( options )
1112 execute "CREATE DATABASE #{ name } #{ db_options } #{ edition_options } "
13+ execute "ALTER DATABASE #{ name } SET #{ compatibility_options } " if compatibility_options . present?
1214 end
1315
1416 def drop_database ( database )
@@ -31,6 +33,19 @@ def collation
3133
3234 private
3335
36+ def create_database_compatibility_options ( options = { } )
37+ keys = [ :compatibility_level ]
38+ copts = @connection_parameters
39+ options = {
40+ compatibility_level : copts [ :compatibility_level ]
41+ } . merge ( options . symbolize_keys ) . select { |_ , v |
42+ v . present?
43+ } . slice ( *keys ) . map { |k , v |
44+ "#{ k . to_s . upcase } = #{ v } "
45+ } . join ( " " )
46+ options
47+ end
48+
3449 def create_database_options ( options = { } )
3550 keys = [ :collate ]
3651 copts = @connection_parameters
You can’t perform that action at this time.
0 commit comments