pg_online_schema_change 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4b544005274743fc18f3147204997861e3ac55e7c619a6859849049eff42324
4
- data.tar.gz: a4123844149ed79c7e8781588ca055f49954afa245a7a63c50886e076be9562e
3
+ metadata.gz: 839fe414842291d9118a4115a56e06f1e0308ab3b7a740cafd9994314ded2d76
4
+ data.tar.gz: 22e9639093bf386f8a1e554e15e8d83df5e3c6de340c372f181fa3b280aee98d
5
5
  SHA512:
6
- metadata.gz: d5b08b1f26c9d3f3c19d819cf65d0787bbbd6221845ce44bcf2aaf13a0389f8824139d3034507cb8118751b2e09713ec4116322e8b86b8988276d6ab8f4a2390
7
- data.tar.gz: e5e589f58797e28fbe15fd355367a61c2673f6d90ccadb67c9b43427ea0a5b86afba9da4ec5199dd4656397f4c7a5e8b27a3805876915d7eddb8366a19892a4b
6
+ metadata.gz: a160d19b3f1cb6655f70e0481b3293110deaee04d7a017ff9fe0c2b4d6100fd7d475520092db1b3bb5e068df5cb70243a00397a5cb1c2c259f2fe5b776b7e405
7
+ data.tar.gz: 9e4543fde48359fdc12046ff019420aafe51732f5cd1332285b3762fac3dcb198acc7be4f5fc6f6f90b910532758eb4a5752a8c9835d1f394774e6f77eda3898
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [0.9.5] - 2023-10-15
2
+
3
+ - Validate one constraint at a time in #124
4
+ - Introduce --skip-foreign-key-validation in #125
5
+
1
6
  ## [0.9.4] - 2023-09-17
2
7
 
3
8
  - Resolving gem push and sync glitch in 0.9.3
@@ -13,6 +18,7 @@
13
18
 
14
19
  - Dependency updates
15
20
  - Create shadow and audit with auatovacuum default turned off. Should avoid lock queues when disabling vacuum on audit table. #97
21
+
16
22
  ## [0.9.1] - 2023-06-24
17
23
 
18
24
  - Dependency updates and refresh docker release process with multi-platform build
data/Gemfile.lock CHANGED
@@ -1,21 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pg_online_schema_change (0.9.5)
4
+ pg_online_schema_change (0.9.6)
5
5
  ougai (~> 2.0.0)
6
6
  pg (>= 1.3.2, < 1.6.0)
7
7
  pg_query (>= 2.1.3, < 4.3.0)
8
- thor (~> 1.2.1)
8
+ thor (>= 1.2.1, < 1.4.0)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
13
  ast (2.4.2)
14
- base64 (0.1.1)
15
14
  coderay (1.1.3)
16
15
  diff-lcs (1.5.0)
17
- google-protobuf (3.24.4-arm64-darwin)
18
- google-protobuf (3.24.4-x86_64-linux)
16
+ google-protobuf (3.25.0-arm64-darwin)
19
17
  haml (6.1.1)
20
18
  temple (>= 0.8.2)
21
19
  thor
@@ -27,7 +25,7 @@ GEM
27
25
  ougai (2.0.0)
28
26
  oj (~> 3.10)
29
27
  parallel (1.23.0)
30
- parser (3.2.2.3)
28
+ parser (3.2.2.4)
31
29
  ast (~> 2.4.1)
32
30
  racc
33
31
  pg (1.5.4)
@@ -39,9 +37,9 @@ GEM
39
37
  method_source (~> 1.0)
40
38
  racc (1.7.1)
41
39
  rainbow (3.1.1)
42
- rake (13.0.6)
40
+ rake (13.1.0)
43
41
  rbs (3.1.0)
44
- regexp_parser (2.8.1)
42
+ regexp_parser (2.8.2)
45
43
  rexml (3.2.6)
46
44
  rspec (3.12.0)
47
45
  rspec-core (~> 3.12.0)
@@ -56,19 +54,18 @@ GEM
56
54
  diff-lcs (>= 1.2.0, < 2.0)
57
55
  rspec-support (~> 3.12.0)
58
56
  rspec-support (3.12.0)
59
- rubocop (1.56.4)
60
- base64 (~> 0.1.1)
57
+ rubocop (1.57.2)
61
58
  json (~> 2.3)
62
59
  language_server-protocol (>= 3.17.0)
63
60
  parallel (~> 1.10)
64
- parser (>= 3.2.2.3)
61
+ parser (>= 3.2.2.4)
65
62
  rainbow (>= 2.2.2, < 4.0)
66
63
  regexp_parser (>= 1.8, < 3.0)
67
64
  rexml (>= 3.2.5, < 4.0)
68
65
  rubocop-ast (>= 1.28.1, < 2.0)
69
66
  ruby-progressbar (~> 1.7)
70
67
  unicode-display_width (>= 2.4.0, < 3.0)
71
- rubocop-ast (1.29.0)
68
+ rubocop-ast (1.30.0)
72
69
  parser (>= 3.2.1.0)
73
70
  rubocop-capybara (2.18.0)
74
71
  rubocop (~> 1.41)
@@ -97,7 +94,7 @@ GEM
97
94
  rbs
98
95
  syntax_tree (>= 2.0.1)
99
96
  temple (0.10.0)
100
- thor (1.2.2)
97
+ thor (1.3.0)
101
98
  tilt (2.1.0)
102
99
  unicode-display_width (2.5.0)
103
100
 
data/README.md CHANGED
@@ -9,10 +9,11 @@ pg-online-schema-change (`pg-osc`) is a tool for making schema changes (any `ALT
9
9
 
10
10
  `pg-osc` uses the concept of shadow table to perform schema changes. At a high level, it creates a shadow table that looks structurally the same as the primary table, performs the schema change on the shadow table, copies contents from the primary table to the shadow table and swaps the table names in the end while preserving all changes to the primary table using triggers (via audit table).
11
11
 
12
- `pg-osc` is inspired by the design and workings of tools like `pg_repack` and `pt-online-schema-change` (MySQL). Read more below on [how does it work](#how-does-it-work), [prominent features](#prominent-features), the [caveats](#caveats) and [examples](#examples)
12
+ `pg-osc` is inspired by the design and workings of tools like `pg_repack` and `pt-online-schema-change` (MySQL). Read more below on [how does it work](#how-does-it-work), [prominent features](#prominent-features), the [caveats](#few-things-to-keep-in-mind) and [examples](#examples)
13
13
 
14
14
  ## Table of Contents
15
15
 
16
+ - [Table of Contents](#table-of-contents)
16
17
  - [Installation](#installation)
17
18
  - [Requirements](#requirements)
18
19
  - [Usage](#usage)
@@ -22,15 +23,15 @@ pg-online-schema-change (`pg-osc`) is a tool for making schema changes (any `ALT
22
23
  - [Renaming a column](#renaming-a-column)
23
24
  - [Multiple ALTER statements](#multiple-alter-statements)
24
25
  - [Kill other backends after 5s](#kill-other-backends-after-5s)
26
+ - [Replaying larger workloads](#replaying-larger-workloads)
25
27
  - [Backfill data](#backfill-data)
26
28
  - [Running using Docker](#running-using-docker)
27
- - [Caveats](#caveats)
29
+ - [Few things to keep in mind](#few-things-to-keep-in-mind)
28
30
  - [How does it work](#how-does-it-work)
29
31
  - [Development](#development)
32
+ - [Local testing](#local-testing)
30
33
  - [Releasing](#releasing)
31
34
  - [Contributing](#contributing)
32
- - [License](#license)
33
- - [Code of Conduct](#code-of-conduct)
34
35
 
35
36
  ## Installation
36
37
 
@@ -103,7 +104,7 @@ print the version
103
104
  ## Prominent features
104
105
 
105
106
  - `pg-osc` supports when a column is being added, dropped or renamed with no data loss.
106
- - `pg-osc` acquires minimal locks throughout the process (read more below on the caveats).
107
+ - `pg-osc` acquires minimal locks throughout the process (read more below on the [caveats](#few-things-to-keep-in-mind)).
107
108
  - Copies over indexes and Foreign keys.
108
109
  - Optionally drop or retain old tables in the end.
109
110
  - Tune how slow or fast should replays be from the audit/log table ([Replaying larger workloads](#replaying-larger-workloads)).
@@ -216,7 +217,7 @@ docker run --network host -it --rm shayonj/pg-osc:latest \
216
217
  --drop
217
218
  ```
218
219
 
219
- ## Caveats
220
+ ## Few things to keep in mind
220
221
 
221
222
  - Partitioned tables are not supported as of yet. Pull requests and ideas welcome.
222
223
  - A primary key should exist on the table; without it, `pg-osc` will raise an exception
@@ -229,8 +230,6 @@ docker run --network host -it --rm shayonj/pg-osc:latest \
229
230
  - Due to the nature of duplicating a table, there needs to be enough space on the disk to support the operation.
230
231
  - Index, constraints and sequence names will be altered and lose their original naming.
231
232
  - Can be fixed in future releases. Feel free to open a feature req.
232
- - Triggers are not carried over.
233
- - Can be fixed in future releases. Feel free to open a feature req.
234
233
  - Foreign keys are dropped & re-added to referencing tables with a `NOT VALID`. A follow on `VALIDATE CONSTRAINT` is run.
235
234
  - Ensures that integrity is maintained and re-introducing FKs doesn't acquire additional locks, hence the `NOT VALID`.
236
235
 
@@ -297,11 +296,3 @@ bundle exec bin/pg-online-schema-change perform -a 'ALTER TABLE pgbench_accounts
297
296
  ## Contributing
298
297
 
299
298
  Bug reports and pull requests are welcome on GitHub at https://github.com/shayonj/pg-osc.
300
-
301
- ## License
302
-
303
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
304
-
305
- ## Code of Conduct
306
-
307
- Everyone interacting in the PgOnlineSchemaChange project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/shayonj/pg-osc/blob/main/CODE_OF_CONDUCT.md).
@@ -311,20 +311,25 @@ module PgOnlineSchemaChange
311
311
 
312
312
  def view_definitions_for(client, table)
313
313
  query = <<~SQL
314
- SELECT DISTINCT dependent_view.relname as view_name, pg_get_viewdef(format('%I.%I', '#{client.schema}', dependent_view.relname)::regclass) as view_definition
315
- FROM pg_depend
316
- JOIN pg_rewrite ON pg_depend.objid = pg_rewrite.oid
317
- JOIN pg_class as dependent_view ON pg_rewrite.ev_class = dependent_view.oid
318
- JOIN pg_class as source_table ON pg_depend.refobjid = source_table.oid
319
- JOIN pg_namespace source_ns ON source_ns.oid = source_table.relnamespace
320
- WHERE
321
- source_ns.nspname = '#{client.schema}'
322
- AND source_table.relname = '#{table}'
314
+ SELECT DISTINCT
315
+ dependent_view.relname AS view_name,
316
+ pg_get_viewdef(dependent_view.oid) AS view_definition,
317
+ view_ns.nspname AS schema_name
318
+ FROM pg_class AS source_table
319
+ JOIN pg_depend ON pg_depend.refobjid = source_table.oid
320
+ JOIN pg_rewrite ON pg_rewrite.oid = pg_depend.objid
321
+ JOIN pg_class AS dependent_view ON dependent_view.oid = pg_rewrite.ev_class
322
+ JOIN pg_namespace AS view_ns ON dependent_view.relnamespace = view_ns.oid
323
+ AND dependent_view.relkind = 'v'
324
+ AND source_table.relname = '#{table}';
323
325
  SQL
324
326
 
325
327
  definitions = []
326
328
  run(client.connection, query) do |result|
327
- definitions = result.map { |row| { row["view_name"] => row["view_definition"].strip } }
329
+ definitions =
330
+ result.map do |row|
331
+ { "#{row["schema_name"]}.#{row["view_name"]}" => row["view_definition"].strip }
332
+ end
328
333
  end
329
334
 
330
335
  definitions
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgOnlineSchemaChange
4
- VERSION = "0.9.5"
4
+ VERSION = "0.9.6"
5
5
  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.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shayon Mukherjee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-15 00:00:00.000000000 Z
11
+ date: 2023-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ougai
@@ -68,16 +68,22 @@ dependencies:
68
68
  name: thor
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "~>"
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: 1.2.1
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: 1.4.0
74
77
  type: :runtime
75
78
  prerelease: false
76
79
  version_requirements: !ruby/object:Gem::Requirement
77
80
  requirements:
78
- - - "~>"
81
+ - - ">="
79
82
  - !ruby/object:Gem::Version
80
83
  version: 1.2.1
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: 1.4.0
81
87
  - !ruby/object:Gem::Dependency
82
88
  name: prettier_print
83
89
  requirement: !ruby/object:Gem::Requirement