(queueName string)
| 203 | } |
| 204 | |
| 205 | func generateCreateTableQuery(queueName string) string { |
| 206 | quotedTableName := pg.QuoteIdentifier(queueName) |
| 207 | return fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %[1]s |
| 208 | ( |
| 209 | id UUID DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY, |
| 210 | created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL, |
| 211 | started_at TIMESTAMPTZ NULL, |
| 212 | locked_until TIMESTAMPTZ NULL, |
| 213 | processed_at TIMESTAMPTZ NULL, |
| 214 | consumed_count INTEGER DEFAULT 0 NOT NULL, |
| 215 | error_detail TEXT NULL, |
| 216 | payload JSONB NOT NULL, |
| 217 | metadata JSONB NOT NULL |
| 218 | ); |
| 219 | CREATE INDEX IF NOT EXISTS "%[2]s_created_at_idx" ON %[1]s (created_at); |
| 220 | CREATE INDEX IF NOT EXISTS "%[2]s_processed_at_null_idx" ON %[1]s (processed_at) WHERE (processed_at IS NULL); |
| 221 | `, quotedTableName, quotedTableName[1:len(quotedTableName)-1]) |
| 222 | } |
| 223 | |
| 224 | func generateCreateTableQueryCompositeIndex(queueName string) string { |
| 225 | quotedTableName := pg.QuoteIdentifier(queueName) |
no test coverage detected