MCPcopy Create free account
hub / github.com/dataddo/pgq / generateCreateTablePartitionedQuery

Function generateCreateTablePartitionedQuery

validator_test.go:243–261  ·  view source on GitHub ↗
(queueName string)

Source from the content-addressed store, hash-verified

241}
242
243func generateCreateTablePartitionedQuery(queueName string) string {
244 quotedTableName := pg.QuoteIdentifier(queueName)
245 return fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %[1]s
246 (
247 id UUID DEFAULT gen_random_uuid() NOT NULL,
248 created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
249 started_at TIMESTAMPTZ NULL,
250 locked_until TIMESTAMPTZ NULL,
251 processed_at TIMESTAMPTZ NULL,
252 consumed_count INTEGER DEFAULT 0 NOT NULL,
253 error_detail TEXT NULL,
254 payload JSONB NOT NULL,
255 metadata JSONB NOT NULL
256 ) PARTITION BY RANGE (created_at);
257 CREATE TABLE "%[2]s_y2024m02" PARTITION OF %[1]s FOR VALUES FROM ('2024-01-01') TO ('2024-02-01');
258 CREATE INDEX IF NOT EXISTS "%[2]s_created_at_idx" ON %[1]s (created_at);
259 CREATE INDEX IF NOT EXISTS "%[2]s_processed_at_null_idx" ON %[1]s (processed_at) WHERE (processed_at IS NULL);
260 `, quotedTableName, quotedTableName[1:len(quotedTableName)-1])
261}
262
263func generateDropTableQuery(queueName string) string {
264 quotedTableName := pg.QuoteIdentifier(queueName)

Calls 1

QuoteIdentifierFunction · 0.92

Tested by

no test coverage detected