pg_online_schema_change 0.7.1 → 0.7.3
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 +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +3 -3
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +2 -2
- data/README.md +11 -0
- data/lib/pg_online_schema_change/orchestrate.rb +3 -0
- data/lib/pg_online_schema_change/query.rb +22 -0
- data/lib/pg_online_schema_change/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70f01145ab63bcb06e4aea9e79b8dc5ac1bf5cc37749964589d2dc940214d8c4
|
4
|
+
data.tar.gz: 52f2b7e5fe1b793f1f8a414972d282a41661eb0045b65d095b65b4c9ab2d6a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4d0c36d71d4aa8020063c63bba2358ffd2d088ad9da21ce3419a8916acbd74c80dfefd5a134423e708ef6b72f444dcbf0ebfd6ba4ff26956d562c258a94fbcc
|
7
|
+
data.tar.gz: c73369d1a69a0824474d5a930411b2f2eee0e7ac61986fb7b8df47d84e010da2cb35fec6e054e5e8986e6877f1992f256b420404a41f1cdd85620f8f1b9a3bb1
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-
|
3
|
+
# on 2022-09-24 14:22:44 UTC using RuboCop version 1.23.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -9,7 +9,7 @@
|
|
9
9
|
# Offense count: 2
|
10
10
|
# Configuration parameters: CountComments, CountAsOne.
|
11
11
|
Metrics/ClassLength:
|
12
|
-
Max:
|
12
|
+
Max: 266
|
13
13
|
|
14
14
|
# Offense count: 2
|
15
15
|
# Configuration parameters: IgnoredMethods.
|
@@ -26,7 +26,7 @@ Packaging/GemspecGit:
|
|
26
26
|
Exclude:
|
27
27
|
- 'pg_online_schema_change.gemspec'
|
28
28
|
|
29
|
-
# Offense count:
|
29
|
+
# Offense count: 68
|
30
30
|
# Configuration parameters: CountAsOne.
|
31
31
|
RSpec/ExampleLength:
|
32
32
|
Max: 55
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
|
2
|
-
## [0.
|
2
|
+
## [0.7.2] - 2022-09-17
|
3
|
+
* Update primary key sequence on shadow table https://github.com/shayonj/pg-osc/pull/72
|
4
|
+
- Thanks to @brycethornton for the report
|
5
|
+
|
6
|
+
## [0.7.1] - 2022-03-13
|
7
|
+
* Bump pg to `1.3.4` https://github.com/shayonj/pg-osc/commit/d086c19d4f273dc960491cbedf9e0602d812896b
|
8
|
+
|
9
|
+
## [0.7.0] - 2022-03-13
|
3
10
|
* Move CI to Github Actions in https://github.com/shayonj/pg-osc/pull/64
|
4
11
|
* Set --password as optional since it is deprecated in https://github.com/shayonj/pg-osc/pull/66
|
5
12
|
* Smoke tests in https://github.com/shayonj/pg-osc/pull/65
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pg_online_schema_change (0.7.
|
4
|
+
pg_online_schema_change (0.7.3)
|
5
5
|
ougai (~> 2.0.0)
|
6
6
|
pg (~> 1.3.2)
|
7
7
|
pg_query (~> 2.1.3)
|
@@ -14,7 +14,6 @@ GEM
|
|
14
14
|
coderay (1.1.3)
|
15
15
|
diff-lcs (1.5.0)
|
16
16
|
google-protobuf (3.19.4)
|
17
|
-
google-protobuf (3.19.4-x86_64-linux)
|
18
17
|
method_source (1.0.0)
|
19
18
|
oj (3.13.11)
|
20
19
|
ougai (2.0.0)
|
@@ -71,6 +70,7 @@ GEM
|
|
71
70
|
|
72
71
|
PLATFORMS
|
73
72
|
arm64-darwin-20
|
73
|
+
arm64-darwin-21
|
74
74
|
x86_64-linux
|
75
75
|
|
76
76
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -205,6 +205,7 @@ docker run --network host -it --rm shayonj/pg-osc:latest \
|
|
205
205
|
--drop
|
206
206
|
```
|
207
207
|
## Caveats
|
208
|
+
- Partitioned tables are not supported as of yet. Pull requests and ideas welcome.
|
208
209
|
- A primary key should exist on the table; without it, `pg-osc` will raise an exception
|
209
210
|
- This is because - currently there is no other way to uniquely identify rows during replay.
|
210
211
|
- `pg-osc` will acquire `ACCESS EXCLUSIVE` lock on the parent table twice during the operation.
|
@@ -259,6 +260,16 @@ rvm use 3.0.0
|
|
259
260
|
|
260
261
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
261
262
|
|
263
|
+
### Local testing
|
264
|
+
```
|
265
|
+
docker compose up
|
266
|
+
|
267
|
+
pgbench --initialize -s 10 --foreign-keys --host localhost -U jamesbond -d postgres
|
268
|
+
pgbench -T 60000 -c 5 --host localhost -U jamesbond -d postgres
|
269
|
+
|
270
|
+
bundle exec bin/pg-online-schema-change perform -a 'ALTER TABLE pgbench_accounts ALTER COLUMN aid TYPE BIGINT' -d "postgres" -h "localhost" -u "jamesbond" -w "password"
|
271
|
+
```
|
272
|
+
|
262
273
|
## Releasing
|
263
274
|
|
264
275
|
- Bump version in `version.rb`
|
@@ -238,7 +238,10 @@ module PgOnlineSchemaChange
|
|
238
238
|
rows = Replay.rows_to_play(opened)
|
239
239
|
Replay.play!(rows, opened)
|
240
240
|
|
241
|
+
query_for_primary_key_refresh = Query.query_for_primary_key_refresh(shadow_table, primary_key, client.table, opened)
|
242
|
+
|
241
243
|
sql = <<~SQL
|
244
|
+
#{query_for_primary_key_refresh};
|
242
245
|
ALTER TABLE #{client.table} RENAME to #{old_primary_table};
|
243
246
|
ALTER TABLE #{shadow_table} RENAME to #{client.table};
|
244
247
|
#{referential_foreign_key_statements}
|
@@ -319,6 +319,28 @@ module PgOnlineSchemaChange
|
|
319
319
|
FROM ONLY #{client.table}
|
320
320
|
SQL
|
321
321
|
end
|
322
|
+
|
323
|
+
def primary_key_sequence(shadow_table, primary_key, opened)
|
324
|
+
query = <<~SQL
|
325
|
+
SELECT pg_get_serial_sequence(\'#{shadow_table}\', \'#{primary_key}\') as sequence_name
|
326
|
+
SQL
|
327
|
+
|
328
|
+
result = run(client.connection, query, opened)
|
329
|
+
|
330
|
+
result.map do |row|
|
331
|
+
row["sequence_name"]
|
332
|
+
end&.first
|
333
|
+
end
|
334
|
+
|
335
|
+
def query_for_primary_key_refresh(shadow_table, primary_key, table, opened)
|
336
|
+
sequence_name = primary_key_sequence(shadow_table, primary_key, opened)
|
337
|
+
|
338
|
+
return "" if sequence_name.nil?
|
339
|
+
|
340
|
+
<<~SQL
|
341
|
+
SELECT setval((select pg_get_serial_sequence(\'#{shadow_table}\', \'#{primary_key}\')), (SELECT max(#{primary_key}) FROM #{table})+1);
|
342
|
+
SQL
|
343
|
+
end
|
322
344
|
end
|
323
345
|
end
|
324
346
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_online_schema_change
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shayon Mukherjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ougai
|