@@ -398,22 +398,38 @@ defmodule Ecto.Adapters.Exqlite.Connection do
398398 end
399399
400400 @ impl true
401- def execute_ddl ( { command , % Index { } = index } )
402- when command in [ :create , :create_if_not_exists ] do
401+ def execute_ddl ( { :create , % Index { } = index } ) do
403402 fields = intersperse_map ( index . columns , ", " , & index_expr / 1 )
404403
405404 [
406405 [
407406 "CREATE " ,
408407 if_do ( index . unique , "UNIQUE " ) ,
409- "INDEX" ,
410- if_do ( command == :create_if_not_exists , " IF NOT EXISTS" ) ,
411- ?\s ,
408+ "INDEX " ,
412409 quote_name ( index . name ) ,
413410 " ON " ,
414411 quote_table ( index . prefix , index . table ) ,
415- ?\s ,
416- ?( ,
412+ " (" ,
413+ fields ,
414+ ?) ,
415+ if_do ( index . where , [ " WHERE " , to_string ( index . where ) ] )
416+ ]
417+ ]
418+ end
419+
420+ @ impl true
421+ def execute_ddl ( { :create_if_not_exists , % Index { } = index } ) do
422+ fields = intersperse_map ( index . columns , ", " , & index_expr / 1 )
423+
424+ [
425+ [
426+ "CREATE " ,
427+ if_do ( index . unique , "UNIQUE " ) ,
428+ "INDEX IF NOT EXISTS " ,
429+ quote_name ( index . name ) ,
430+ " ON " ,
431+ quote_table ( index . prefix , index . table ) ,
432+ " (" ,
417433 fields ,
418434 ?) ,
419435 if_do ( index . where , [ " WHERE " , to_string ( index . where ) ] )
0 commit comments