github.com/iasthc/atlas/cmd/atlas@v0.0.0-20230523071841-73246df3f88d/internal/cmdapi/testdata/import/goose/2_second_migration.sql (about) 1 2 3 4 -- +goose Up 5 6 7 ALTER TABLE post ADD updated_at TIMESTAMP NOT NULL; 8 9 -- +goose StatementBegin 10 -- Comment for the function declaration. 11 CREATE 12 OR REPLACE FUNCTION histories_partition_creation( DATE, DATE ) 13 returns void AS $$ 14 DECLARE 15 create_query text; 16 BEGIN 17 FOR create_query IN 18 SELECT 'CREATE TABLE IF NOT EXISTS histories_' 19 || TO_CHAR(d, 'YYYY_MM') 20 || ' ( CHECK( created_at >= timestamp ''' 21 || TO_CHAR(d, 'YYYY-MM-DD 00:00:00') 22 || ''' AND created_at < timestamp ''' 23 || TO_CHAR(d + INTERVAL '1 month', 'YYYY-MM-DD 00:00:00') 24 || ''' ) ) inherits ( histories );' 25 FROM generate_series($1, $2, '1 month') AS d LOOP 26 EXECUTE create_query; 27 END LOOP; -- LOOP END 28 END; -- FUNCTION END 29 $$ 30 language plpgsql; 31 -- +goose StatementEnd