pgslice 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df319dee9da69596907cb6c50714a3c49bcfd86eae5a230f2e26c460266c5b66
4
- data.tar.gz: 81149e6d3ec75fd57988c534932b226850617ce78a2b66d75cd101de8c117478
3
+ metadata.gz: 325b5cd0c6ec6dfa7a98db88a06bb47ed4f8ee327c6c21dddfd897ec13f54533
4
+ data.tar.gz: aabbfee0e2bced3b7e93f4d9f0db218db060779a3b75b14ac7056867901bae26
5
5
  SHA512:
6
- metadata.gz: 8f7e3242e5d5ad1476be31537a3abfdbec0323fa797eaee514e5f3fc8da047402647c1b3b2940bccc7202215933f41c12b4aa7d1471eb65ea844d895673abcb1
7
- data.tar.gz: a198cd6f0efa32403cdd498749b5f886ebc41bb209535cbd85ae88ceb07ece537706a25828280a0a6a87d04865a218c8f330305fba434e374a1ef68c30d4eadb
6
+ metadata.gz: ba7310102950041d8247779282b6b252d40d7c824bd03b07d08ed7e400534cbf44eb31161595004ff782ccdaa9eacd0d6698797068ea06109ef974eebab8439b
7
+ data.tar.gz: 50faa245fb1ac68b6b685af8529277f23a46146477fd37e9ec52a6984222daa3392ca49e9d5276f03177f755ccec5c94989d4f6f25e182f3013ed9b24a8a7250
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.7.0 (2025-05-26)
2
+
3
+ - Dropped support for Ruby < 3
4
+ - Dropped support for Postgres < 13
5
+
1
6
  ## 0.6.1 (2023-04-26)
2
7
 
3
8
  - Fixed `uninitialized constant` error
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016-2023 Andrew Kane
3
+ Copyright (c) 2016-2025 Andrew Kane
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -4,7 +4,7 @@ Postgres partitioning as easy as pie. Works great for both new and existing tabl
4
4
 
5
5
  :tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
6
6
 
7
- [![Build Status](https://github.com/ankane/pgslice/workflows/build/badge.svg?branch=master)](https://github.com/ankane/pgslice/actions)
7
+ [![Build Status](https://github.com/ankane/pgslice/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/pgslice/actions)
8
8
 
9
9
  ## Install
10
10
 
@@ -92,11 +92,11 @@ pgslice prep visits created_at month
92
92
  ```sql
93
93
  BEGIN;
94
94
 
95
- CREATE TABLE "public"."visits_intermediate" (LIKE "public"."visits" INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING STORAGE INCLUDING COMMENTS) PARTITION BY RANGE ("created_at");
95
+ CREATE TABLE "public"."visits_intermediate" (LIKE "public"."visits" INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING STORAGE INCLUDING COMMENTS INCLUDING STATISTICS INCLUDING GENERATED INCLUDING COMPRESSION) PARTITION BY RANGE ("created_at");
96
96
 
97
97
  CREATE INDEX ON "public"."visits_intermediate" USING btree ("created_at");
98
98
 
99
- COMMENT ON TABLE "public"."visits_intermediate" is 'column:createdAt,period:day,cast:date,version:3';
99
+ COMMENT ON TABLE "public"."visits_intermediate" is 'column:created_at,period:month,cast:date,version:3';
100
100
 
101
101
  COMMIT;
102
102
  ```
@@ -108,17 +108,17 @@ pgslice add_partitions visits --intermediate --past 1 --future 1
108
108
  ```sql
109
109
  BEGIN;
110
110
 
111
- CREATE TABLE "public"."visits_202208" PARTITION OF "public"."visits_intermediate" FOR VALUES FROM ('2022-08-01') TO ('2022-09-01');
111
+ CREATE TABLE "public"."visits_202408" PARTITION OF "public"."visits_intermediate" FOR VALUES FROM ('2024-08-01') TO ('2024-09-01');
112
112
 
113
- ALTER TABLE "public"."visits_202208" ADD PRIMARY KEY ("id");
113
+ ALTER TABLE "public"."visits_202408" ADD PRIMARY KEY ("id");
114
114
 
115
- CREATE TABLE "public"."visits_202209" PARTITION OF "public"."visits_intermediate" FOR VALUES FROM ('2022-09-01') TO ('2022-10-01');
115
+ CREATE TABLE "public"."visits_202409" PARTITION OF "public"."visits_intermediate" FOR VALUES FROM ('2024-09-01') TO ('2024-10-01');
116
116
 
117
- ALTER TABLE "public"."visits_202209" ADD PRIMARY KEY ("id");
117
+ ALTER TABLE "public"."visits_202409" ADD PRIMARY KEY ("id");
118
118
 
119
- CREATE TABLE "public"."visits_202210" PARTITION OF "public"."visits_intermediate" FOR VALUES FROM ('2022-10-01') TO ('2022-11-01');
119
+ CREATE TABLE "public"."visits_202410" PARTITION OF "public"."visits_intermediate" FOR VALUES FROM ('2024-10-01') TO ('2024-11-01');
120
120
 
121
- ALTER TABLE "public"."visits_202210" ADD PRIMARY KEY ("id");
121
+ ALTER TABLE "public"."visits_202410" ADD PRIMARY KEY ("id");
122
122
 
123
123
  COMMIT;
124
124
  ```
@@ -131,17 +131,17 @@ pgslice fill visits
131
131
  /* 1 of 3 */
132
132
  INSERT INTO "public"."visits_intermediate" ("id", "user_id", "ip", "created_at")
133
133
  SELECT "id", "user_id", "ip", "created_at" FROM "public"."visits"
134
- WHERE "id" > 0 AND "id" <= 10000 AND "created_at" >= '2022-08-01'::date AND "created_at" < '2022-11-01'::date
134
+ WHERE "id" > 0 AND "id" <= 10000 AND "created_at" >= '2024-08-01'::date AND "created_at" < '2024-11-01'::date
135
135
 
136
136
  /* 2 of 3 */
137
137
  INSERT INTO "public"."visits_intermediate" ("id", "user_id", "ip", "created_at")
138
138
  SELECT "id", "user_id", "ip", "created_at" FROM "public"."visits"
139
- WHERE "id" > 10000 AND "id" <= 20000 AND "created_at" >= '2022-08-01'::date AND "created_at" < '2022-11-01'::date
139
+ WHERE "id" > 10000 AND "id" <= 20000 AND "created_at" >= '2024-08-01'::date AND "created_at" < '2024-11-01'::date
140
140
 
141
141
  /* 3 of 3 */
142
142
  INSERT INTO "public"."visits_intermediate" ("id", "user_id", "ip", "created_at")
143
143
  SELECT "id", "user_id", "ip", "created_at" FROM "public"."visits"
144
- WHERE "id" > 20000 AND "id" <= 30000 AND "created_at" >= '2022-08-01'::date AND "created_at" < '2022-11-01'::date
144
+ WHERE "id" > 20000 AND "id" <= 30000 AND "created_at" >= '2024-08-01'::date AND "created_at" < '2024-11-01'::date
145
145
  ```
146
146
 
147
147
  ```sh
@@ -149,11 +149,11 @@ pgslice analyze visits
149
149
  ```
150
150
 
151
151
  ```sql
152
- ANALYZE VERBOSE "public"."visits_202208";
152
+ ANALYZE VERBOSE "public"."visits_202408";
153
153
 
154
- ANALYZE VERBOSE "public"."visits_202209";
154
+ ANALYZE VERBOSE "public"."visits_202409";
155
155
 
156
- ANALYZE VERBOSE "public"."visits_202210";
156
+ ANALYZE VERBOSE "public"."visits_202410";
157
157
 
158
158
  ANALYZE VERBOSE "public"."visits_intermediate";
159
159
  ```
@@ -217,14 +217,14 @@ WHERE
217
217
  Back up and drop older partitions each day, month, or year.
218
218
 
219
219
  ```sh
220
- pg_dump -c -Fc -t <table>_202209 $PGSLICE_URL > <table>_202209.dump
221
- psql -c "DROP TABLE <table>_202209" $PGSLICE_URL
220
+ pg_dump -c -Fc -t <table>_202409 $PGSLICE_URL > <table>_202409.dump
221
+ psql -c "DROP TABLE <table>_202409" $PGSLICE_URL
222
222
  ```
223
223
 
224
224
  If you use [Amazon S3](https://aws.amazon.com/s3/) for backups, [s3cmd](https://github.com/s3tools/s3cmd) is a nice tool.
225
225
 
226
226
  ```sh
227
- s3cmd put <table>_202209.dump s3://<s3-bucket>/<table>_202209.dump
227
+ s3cmd put <table>_202409.dump s3://<s3-bucket>/<table>_202409.dump
228
228
  ```
229
229
 
230
230
  ## Schema Updates
@@ -267,7 +267,7 @@ SELECT * FROM
267
267
  WHERE
268
268
  user_id = 123 AND
269
269
  -- for performance
270
- created_at >= '2022-09-01' AND created_at < '2022-09-02'
270
+ created_at >= '2024-09-01' AND created_at < '2024-09-02'
271
271
  ```
272
272
 
273
273
  For this to be effective, ensure `constraint_exclusion` is set to `partition` (the default value) or `on`.
@@ -374,6 +374,10 @@ Also check out:
374
374
  - [PgHero](https://github.com/ankane/pghero) - A performance dashboard for Postgres
375
375
  - [pgsync](https://github.com/ankane/pgsync) - Sync Postgres data to your local machine
376
376
 
377
+ ## History
378
+
379
+ View the [changelog](https://github.com/ankane/pgslice/blob/master/CHANGELOG.md)
380
+
377
381
  ## Contributing
378
382
 
379
383
  Everyone is encouraged to help improve this project. Here are a few ways you can help:
@@ -396,7 +400,7 @@ bundle exec rake test
396
400
  To test against different versions of Postgres with Docker, use:
397
401
 
398
402
  ```sh
399
- docker run -p=8000:5432 postgres:14
403
+ docker run -p=8000:5432 postgres:16
400
404
  TZ=Etc/UTC PGSLICE_URL=postgres://postgres@localhost:8000/postgres bundle exec rake
401
405
  ```
402
406
 
@@ -4,7 +4,7 @@ module PgSlice
4
4
  option :partition, type: :boolean, default: true, desc: "Partition the table"
5
5
  option :trigger_based, type: :boolean, default: false, desc: "Use trigger-based partitioning"
6
6
  option :test_version, type: :numeric, hide: true
7
- def prep(table, column=nil, period=nil)
7
+ def prep(table, column = nil, period = nil)
8
8
  table = create_table(table)
9
9
  intermediate_table = table.intermediate_table
10
10
  trigger_name = table.trigger_name
@@ -41,8 +41,8 @@ module PgSlice
41
41
  say message
42
42
  end
43
43
  @server_version_num = conn.exec("SHOW server_version_num")[0]["server_version_num"].to_i
44
- if @server_version_num < 110000
45
- abort "This version of pgslice requires Postgres 11+"
44
+ if @server_version_num < 130000
45
+ abort "This version of pgslice requires Postgres 13+"
46
46
  end
47
47
  conn
48
48
  end
data/lib/pgslice/table.rb CHANGED
@@ -16,7 +16,7 @@ module PgSlice
16
16
  end
17
17
 
18
18
  def columns
19
- execute("SELECT column_name FROM information_schema.columns WHERE table_schema = $1 AND table_name = $2 AND is_generated = 'NEVER'", [schema, name]).map{ |r| r["column_name"] }
19
+ execute("SELECT column_name FROM information_schema.columns WHERE table_schema = $1 AND table_name = $2 AND is_generated = 'NEVER'", [schema, name]).map { |r| r["column_name"] }
20
20
  end
21
21
 
22
22
  # http://www.dbforums.com/showthread.php?1667561-How-to-list-sequences-and-the-columns-by-SQL
@@ -1,3 +1,3 @@
1
1
  module PgSlice
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgslice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-04-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: pg
@@ -38,7 +37,6 @@ dependencies:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
- description:
42
40
  email: andrew@ankane.org
43
41
  executables:
44
42
  - pgslice
@@ -65,7 +63,6 @@ homepage: https://github.com/ankane/pgslice
65
63
  licenses:
66
64
  - MIT
67
65
  metadata: {}
68
- post_install_message:
69
66
  rdoc_options: []
70
67
  require_paths:
71
68
  - lib
@@ -73,15 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
70
  requirements:
74
71
  - - ">="
75
72
  - !ruby/object:Gem::Version
76
- version: '2.7'
73
+ version: '3'
77
74
  required_rubygems_version: !ruby/object:Gem::Requirement
78
75
  requirements:
79
76
  - - ">="
80
77
  - !ruby/object:Gem::Version
81
78
  version: '0'
82
79
  requirements: []
83
- rubygems_version: 3.4.10
84
- signing_key:
80
+ rubygems_version: 3.6.7
85
81
  specification_version: 4
86
82
  summary: Postgres partitioning as easy as pie
87
83
  test_files: []