@@ -29,6 +29,22 @@ class SybaseGrammar extends Grammar {
29
29
'numeric '
30
30
];
31
31
32
+ /**
33
+ * Verify if $str length is lower to 30 characters.
34
+ *
35
+ * @return string
36
+ */
37
+ public function limit30Characters ($ str )
38
+ {
39
+ if (strlen ($ str ) > 30 ) {
40
+ $ result = substr ($ str , 0 , 30 );
41
+ } else {
42
+ $ result = $ str ;
43
+ }
44
+
45
+ return $ result ;
46
+ }
47
+
32
48
/**
33
49
* Compile the query to determine if a table exists.
34
50
*
@@ -106,12 +122,7 @@ public function compilePrimary(Blueprint $blueprint, Fluent $command)
106
122
107
123
$ table = $ this ->wrapTable ($ blueprint );
108
124
109
- // Verify if constraint length is lower to 30 characters.
110
- if (strlen ($ command ->index ) > 30 ) {
111
- $ constraint = substr ($ command ->index , 0 , 30 );
112
- } else {
113
- $ constraint = $ command ->index ;
114
- }
125
+ $ constraint = $ this ->limit30Characters ($ command ->index );
115
126
116
127
return "
117
128
ALTER TABLE {$ table }
@@ -132,7 +143,9 @@ public function compileUnique(Blueprint $blueprint, Fluent $command)
132
143
133
144
$ table = $ this ->wrapTable ($ blueprint );
134
145
135
- return "CREATE UNIQUE INDEX {$ command ->index } ON {$ table } ( {$ columns }) " ;
146
+ $ index = $ this ->limit30Characters ($ command ->index );
147
+
148
+ return "CREATE UNIQUE INDEX {$ index } ON {$ table } ( {$ columns }) " ;
136
149
}
137
150
138
151
/**
@@ -148,7 +161,9 @@ public function compileIndex(Blueprint $blueprint, Fluent $command)
148
161
149
162
$ table = $ this ->wrapTable ($ blueprint );
150
163
151
- return "CREATE INDEX {$ command ->index } ON {$ table } ( {$ columns }) " ;
164
+ $ index = $ this ->limit30Characters ($ command ->index );
165
+
166
+ return "CREATE INDEX {$ index } ON {$ table } ( {$ columns }) " ;
152
167
}
153
168
154
169
/**
0 commit comments