{"id":20078510,"url":"https://github.com/amenzhinsky/postgresql-partitioning-scripts","last_synced_at":"2025-09-01T18:39:44.600Z","repository":{"id":95388929,"uuid":"158075230","full_name":"amenzhinsky/postgresql-partitioning-scripts","owner":"amenzhinsky","description":"PostgreSQL Partitioning Scripts","archived":false,"fork":false,"pushed_at":"2024-11-12T17:46:37.000Z","size":11,"stargazers_count":6,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T05:26:21.777Z","etag":null,"topics":["bash","postgresql","sql"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amenzhinsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-18T11:08:51.000Z","updated_at":"2025-02-01T18:55:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"8e28014c-e889-4fd5-af58-020e454a5c10","html_url":"https://github.com/amenzhinsky/postgresql-partitioning-scripts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amenzhinsky%2Fpostgresql-partitioning-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amenzhinsky%2Fpostgresql-partitioning-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amenzhinsky%2Fpostgresql-partitioning-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amenzhinsky%2Fpostgresql-partitioning-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amenzhinsky","download_url":"https://codeload.github.com/amenzhinsky/postgresql-partitioning-scripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252586347,"owners_count":21772282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","postgresql","sql"],"created_at":"2024-11-13T15:14:50.271Z","updated_at":"2025-05-05T22:32:46.887Z","avatar_url":"https://github.com/amenzhinsky.png","language":"Shell","readme":"# PostgreSQL Partitioning Scripts\n\nSet of scripts that may help to automate PostgreSQL partitioning routines. All of them generate SQL code so inspect it thoroughly first before executing.\n\n## partition-table-monthly.bash\n\nPartitions an existing table into a set of child tables for each month beginning with the oldest record (can be overwritten with `FROM` environment variable) and up to the current month, it also creates the default partition table for rows that may violate partition checks in the future.\n\nIt requires some free space at least of the same size as the partitioned table for copying the existing data to new tables.\n\nThe script ensures the lowest down-time by copying data without locking the source table assuming there will be no updates/deletes but inserts. Then it acquire an exclusive lock, copy remaining rows and makes table names switch renaming the old one to `table_name_old` for manual removal.\n\n```bash\n./partition-table-monthly.bash mydatabase orders created_at | psql\n```\n\n## create-monthly-partition.bash\n\nCreates a partition for the previously partitioned table for the upcoming month.\n\n```bash\n./create-monthly-partition.bash orders created_at | psql\n```\n\nYou may also control the current date with `DATE=2018-01-01` environment variable if you need to go back or forward in time..\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famenzhinsky%2Fpostgresql-partitioning-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famenzhinsky%2Fpostgresql-partitioning-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famenzhinsky%2Fpostgresql-partitioning-scripts/lists"}