@@ -537,3 +537,51 @@ Feature: Index definitions in Lua file
537537 schemaname = 'public' AND tablename = 'mytable' AND indexname LIKE '%node_id%'
538538 """
539539
540+ Scenario : Create a unique id index when requested
541+ Given the input file 'liechtenstein-2013-08-03.osm.pbf'
542+ And the lua style
543+ """
544+ local t = osm2pgsql.define_table({
545+ name = 'foo',
546+ ids = { type = 'node', id_column = 'node_id', create_index = 'unique' },
547+ columns = {}
548+ })
549+
550+ function osm2pgsql.process_node(object)
551+ t:insert({})
552+ end
553+ """
554+ When running osm2pgsql flex
555+ Then table foo has 1562 rows
556+ And SELECT indexdef FROM pg_indexes WHERE tablename = 'foo'
557+ | indexdef @fullmatch |
558+ | CREATE UNIQUE INDEX .* USING .*\(node_id \) |
559+ And table pg_catalog.pg_index has 0 rows with condition
560+ """
561+ indrelid = 'foo'::regclass and indisprimary
562+ """
563+
564+ Scenario : Create a primary key id index when requested
565+ Given the input file 'liechtenstein-2013-08-03.osm.pbf'
566+ And the lua style
567+ """
568+ local t = osm2pgsql.define_table({
569+ name = 'foo',
570+ ids = { type = 'node', id_column = 'node_id', create_index = 'primary_key' },
571+ columns = {}
572+ })
573+
574+ function osm2pgsql.process_node(object)
575+ t:insert({})
576+ end
577+ """
578+ When running osm2pgsql flex
579+ Then table foo has 1562 rows
580+ And SELECT indexdef FROM pg_indexes WHERE tablename = 'foo'
581+ | indexdef @fullmatch |
582+ | CREATE UNIQUE INDEX .* USING .*\(node_id \) |
583+ And table pg_catalog.pg_index has 1 row with condition
584+ """
585+ indrelid = 'foo'::regclass and indisprimary
586+ """
587+
0 commit comments