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 = {})
8
8
name = SQLServer ::Utils . extract_identifiers ( database )
9
9
db_options = create_database_options ( options )
10
10
edition_options = create_database_edition_options ( options )
11
+ compatibility_options = create_database_compatibility_options ( options )
11
12
execute "CREATE DATABASE #{ name } #{ db_options } #{ edition_options } "
13
+ execute "ALTER DATABASE #{ name } SET #{ compatibility_options } " if compatibility_options . present?
12
14
end
13
15
14
16
def drop_database ( database )
@@ -31,6 +33,19 @@ def collation
31
33
32
34
private
33
35
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
+
34
49
def create_database_options ( options = { } )
35
50
keys = [ :collate ]
36
51
copts = @connection_parameters
You can’t perform that action at this time.
0 commit comments