@@ -29,6 +29,22 @@ class SybaseGrammar extends Grammar {
2929 'numeric '
3030 ];
3131
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+
3248 /**
3349 * Compile the query to determine if a table exists.
3450 *
@@ -106,12 +122,7 @@ public function compilePrimary(Blueprint $blueprint, Fluent $command)
106122
107123 $ table = $ this ->wrapTable ($ blueprint );
108124
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 );
115126
116127 return "
117128 ALTER TABLE {$ table }
@@ -132,7 +143,9 @@ public function compileUnique(Blueprint $blueprint, Fluent $command)
132143
133144 $ table = $ this ->wrapTable ($ blueprint );
134145
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 }) " ;
136149 }
137150
138151 /**
@@ -148,7 +161,9 @@ public function compileIndex(Blueprint $blueprint, Fluent $command)
148161
149162 $ table = $ this ->wrapTable ($ blueprint );
150163
151- return "CREATE INDEX {$ command ->index } ON {$ table } ( {$ columns }) " ;
164+ $ index = $ this ->limit30Characters ($ command ->index );
165+
166+ return "CREATE INDEX {$ index } ON {$ table } ( {$ columns }) " ;
152167 }
153168
154169 /**
0 commit comments