activerecord-native_db_types_override 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -17
- data/lib/activerecord-native_db_types_override/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -23,19 +23,16 @@ Then run:
|
|
23
23
|
|
24
24
|
In your config/environment.rb or an environment specific configuration, you may specify one or more options in the config hash that will be merged into the default types. The act of configuring does the hash merge/activation of changes.
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
Note: I left the Ruby 1.8 hashrocket notation to show it shouldn't matter. Feel free to use 1.9+ hash syntax.
|
26
|
+
If using Ruby 1.8.x, use hashrocket notation instead for the following examples.
|
29
27
|
|
30
28
|
#### PostgreSQL
|
31
29
|
|
32
30
|
For example, if you want Rails to use the timestamptz type for all datetimes and timestamps created by migrations, you could use:
|
33
31
|
|
34
|
-
require 'active_record/connection_adapters/postgresql_adapter'
|
35
32
|
NativeDbTypesOverride.configure({
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
33
|
+
postgres: {
|
34
|
+
datetime: { name: "timestamptz" },
|
35
|
+
timestamp: { name: "timestamptz" }
|
39
36
|
}
|
40
37
|
})
|
41
38
|
|
@@ -46,8 +43,8 @@ See [PostgreSQLAdapter][postgres_adapter] for the default types.
|
|
46
43
|
For the MySQL/MySQL2 adapters, maybe you could change boolean to a string type:
|
47
44
|
|
48
45
|
NativeDbTypesOverride.configure({
|
49
|
-
:
|
50
|
-
:
|
46
|
+
mysql: {
|
47
|
+
boolean: { name: "varchar", limit: 1 }
|
51
48
|
}
|
52
49
|
})
|
53
50
|
|
@@ -58,8 +55,8 @@ See [AbstractMysqlAdapter][mysql_adapter] for the default types.
|
|
58
55
|
Maybe you need to extend the default string limit from 255 to 4096:
|
59
56
|
|
60
57
|
NativeDbTypesOverride.configure({
|
61
|
-
:
|
62
|
-
:
|
58
|
+
sqlite: {
|
59
|
+
string: { :name: "varchar", limit: 4096 }
|
63
60
|
}
|
64
61
|
})
|
65
62
|
|
@@ -76,10 +73,10 @@ In addition, it's native_database_types method can define boolean as VARCHAR2 (1
|
|
76
73
|
However, if you need to make another change like making datetime and timestamp store timezones *and* you want to emulate_booleans_from_strings, just ensure that you define the boolean shown in the following example rather than using OracleEnhancedAdapter's emulate_booleans_from_strings option:
|
77
74
|
|
78
75
|
NativeDbTypesOverride.configure({
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
76
|
+
oracle: {
|
77
|
+
datetime: { name: "TIMESTAMP WITH TIMEZONE" },
|
78
|
+
timestamp: { name: "TIMESTAMP WITH TIMEZONE" },
|
79
|
+
boolean: { name: "VARCHAR2", limit: 1 }
|
83
80
|
}
|
84
81
|
})
|
85
82
|
|
@@ -96,8 +93,8 @@ Be sure to add a require for the adapter, if it has not been loaded already prio
|
|
96
93
|
require 'active_record/connection_adapters/postgresql_adapter'
|
97
94
|
NativeDbTypesOverride.configure({
|
98
95
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter => {
|
99
|
-
:
|
100
|
-
:
|
96
|
+
datetime: { name: "timestamptz" },
|
97
|
+
timestamp: { name: "timestamptz" }
|
101
98
|
}
|
102
99
|
})
|
103
100
|
|