ar-sequence 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +8 -13
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +5 -1
- data/README.md +1 -1
- data/ar-sequence.gemspec +2 -2
- data/gemfiles/{5_0.gemfile → 6_1.gemfile} +1 -1
- data/gemfiles/{5_1.gemfile → 7_0.gemfile} +1 -1
- data/lib/ar/sequence/adapter.rb +6 -2
- data/lib/ar/sequence/schema_dumper.rb +22 -2
- data/lib/ar/sequence/version.rb +1 -1
- metadata +8 -8
- data/gemfiles/5_2.gemfile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31fd2b32e3b380066c4a9a8a50fa84ed0c880aaec06da39ead297f2d195ac382
|
4
|
+
data.tar.gz: 747332c2d4f177a524dbd212ff4e4f710812c97bf7e409efa5df571963d83de9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2b5de771db2981bf6ee1403b2a96cee69065434c978e1f09a1a210998d63d8bfd33096620fbf82685409d48222a794e166f3409d1edea73a8333fc241e92c96
|
7
|
+
data.tar.gz: 91d0005d29df02998ce1213371dddd75db069f10204349b18456cef296082f4ac2aa33a247b061a0f54d6a001fe9d689b1c4d0df9c67610067cc09a8e1da32b4
|
data/.github/workflows/tests.yml
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
+
---
|
1
2
|
name: Tests
|
2
3
|
|
3
4
|
on:
|
4
5
|
pull_request:
|
5
|
-
branches:
|
6
|
-
- main
|
7
6
|
push:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
schedule:
|
12
|
-
- cron: "0 10 * * *"
|
7
|
+
workflow_dispatch:
|
8
|
+
inputs: {}
|
13
9
|
|
14
10
|
jobs:
|
15
11
|
build:
|
@@ -18,13 +14,12 @@ jobs:
|
|
18
14
|
strategy:
|
19
15
|
fail-fast: false
|
20
16
|
matrix:
|
21
|
-
ruby: [2.
|
17
|
+
ruby: ["2.7", "3.0"]
|
22
18
|
gemfile:
|
23
19
|
- Gemfile
|
20
|
+
- gemfiles/7_0.gemfile
|
21
|
+
- gemfiles/6_1.gemfile
|
24
22
|
- gemfiles/6_0.gemfile
|
25
|
-
- gemfiles/5_2.gemfile
|
26
|
-
- gemfiles/5_1.gemfile
|
27
|
-
- gemfiles/5_0.gemfile
|
28
23
|
|
29
24
|
services:
|
30
25
|
postgres:
|
@@ -35,7 +30,7 @@ jobs:
|
|
35
30
|
--health-retries 5
|
36
31
|
|
37
32
|
steps:
|
38
|
-
- uses: actions/checkout@v2.
|
33
|
+
- uses: actions/checkout@v2.4.0
|
39
34
|
|
40
35
|
- uses: actions/cache@v2
|
41
36
|
with:
|
@@ -48,7 +43,7 @@ jobs:
|
|
48
43
|
hashFiles(matrix.gemfile) }}
|
49
44
|
|
50
45
|
- name: Set up Ruby
|
51
|
-
uses:
|
46
|
+
uses: ruby/setup-ruby@v1
|
52
47
|
with:
|
53
48
|
ruby-version: ${{ matrix.ruby }}
|
54
49
|
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -11,7 +11,11 @@ Prefix your message with one of the following:
|
|
11
11
|
- [Security] in case of vulnerabilities.
|
12
12
|
-->
|
13
13
|
|
14
|
-
## v0.2.
|
14
|
+
## v0.2.1 - 2021-12-21
|
15
|
+
|
16
|
+
- [Changed] Dump schema names that aren't on the default search path.
|
17
|
+
|
18
|
+
## v0.2.0 - 2021-09-16
|
15
19
|
|
16
20
|
- [Changed] Only dump sequences created by ar_sequence (using Postgres COMMENT).
|
17
21
|
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![Gem](https://img.shields.io/gem/v/ar-sequence.svg)](https://rubygems.org/gems/ar-sequence)
|
6
6
|
[![Gem](https://img.shields.io/gem/dt/ar-sequence.svg)](https://rubygems.org/gems/ar-sequence)
|
7
7
|
|
8
|
-
|
8
|
+
Add support for PostgreSQL's `SEQUENCE` on ActiveRecord migrations.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
data/ar-sequence.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = AR::Sequence::VERSION
|
8
8
|
spec.authors = ["Nando Vieira"]
|
9
9
|
spec.email = ["fnando.vieira@gmail.com"]
|
10
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
11
|
-
|
10
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
11
|
+
spec.metadata = {"rubygems_mfa_required" => "true"}
|
12
12
|
spec.summary = "Add support for PostgreSQL's SEQUENCE on " \
|
13
13
|
"ActiveRecord migrations"
|
14
14
|
spec.description = spec.summary
|
data/lib/ar/sequence/adapter.rb
CHANGED
@@ -19,7 +19,7 @@ module AR
|
|
19
19
|
|
20
20
|
def create_sequence(name, options = {})
|
21
21
|
increment = options[:increment] || options[:step]
|
22
|
-
name =
|
22
|
+
name = quote_name(name)
|
23
23
|
|
24
24
|
sql = ["CREATE SEQUENCE IF NOT EXISTS #{name}"]
|
25
25
|
sql << "INCREMENT BY #{increment}" if increment
|
@@ -35,10 +35,14 @@ module AR
|
|
35
35
|
# drop_sequence :user_position
|
36
36
|
#
|
37
37
|
def drop_sequence(name)
|
38
|
-
name =
|
38
|
+
name = quote_name(name)
|
39
39
|
sql = "DROP SEQUENCE #{name}"
|
40
40
|
execute(sql)
|
41
41
|
end
|
42
|
+
|
43
|
+
def quote_name(name)
|
44
|
+
name.split(".", 2).map {|part| quote_column_name(part) }.join(".")
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -8,12 +8,32 @@ module AR
|
|
8
8
|
sequences(stream)
|
9
9
|
end
|
10
10
|
|
11
|
+
def retrieve_search_path
|
12
|
+
user = @connection.select_one("select user").values.first
|
13
|
+
|
14
|
+
@connection
|
15
|
+
.select_one("show search_path")
|
16
|
+
.values
|
17
|
+
.first
|
18
|
+
.split(", ")
|
19
|
+
.map {|path| path == '"$user"' ? user : path }
|
20
|
+
end
|
21
|
+
|
11
22
|
def sequences(stream)
|
12
23
|
sequences = @connection.check_sequences
|
24
|
+
search_path = retrieve_search_path
|
25
|
+
|
13
26
|
return if sequences.empty?
|
14
27
|
|
15
28
|
sequences.each do |seq|
|
16
|
-
|
29
|
+
schema = seq["sequence_schema"]
|
30
|
+
|
31
|
+
sequence_full_name = [
|
32
|
+
search_path.include?(schema) ? nil : schema,
|
33
|
+
seq["sequence_name"]
|
34
|
+
].compact.join(".")
|
35
|
+
|
36
|
+
next unless @connection.custom_sequence?(sequence_full_name)
|
17
37
|
|
18
38
|
start_value = seq["start_value"]
|
19
39
|
increment = seq["increment"]
|
@@ -30,7 +50,7 @@ module AR
|
|
30
50
|
|
31
51
|
statement = [
|
32
52
|
"create_sequence",
|
33
|
-
|
53
|
+
sequence_full_name.inspect
|
34
54
|
].join(" ")
|
35
55
|
|
36
56
|
if options.any?
|
data/lib/ar/sequence/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-sequence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -162,10 +162,9 @@ files:
|
|
162
162
|
- ar-sequence.gemspec
|
163
163
|
- bin/console
|
164
164
|
- bin/setup
|
165
|
-
- gemfiles/5_0.gemfile
|
166
|
-
- gemfiles/5_1.gemfile
|
167
|
-
- gemfiles/5_2.gemfile
|
168
165
|
- gemfiles/6_0.gemfile
|
166
|
+
- gemfiles/6_1.gemfile
|
167
|
+
- gemfiles/7_0.gemfile
|
169
168
|
- lib/ar-sequence.rb
|
170
169
|
- lib/ar/sequence.rb
|
171
170
|
- lib/ar/sequence/adapter.rb
|
@@ -176,7 +175,8 @@ files:
|
|
176
175
|
homepage: https://rubygems.org/gems/ar-sequence
|
177
176
|
licenses:
|
178
177
|
- MIT
|
179
|
-
metadata:
|
178
|
+
metadata:
|
179
|
+
rubygems_mfa_required: 'true'
|
180
180
|
post_install_message:
|
181
181
|
rdoc_options: []
|
182
182
|
require_paths:
|
@@ -185,14 +185,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
185
|
requirements:
|
186
186
|
- - ">="
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
version: 2.
|
188
|
+
version: 2.7.0
|
189
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
190
|
requirements:
|
191
191
|
- - ">="
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
|
-
rubygems_version: 3.2.
|
195
|
+
rubygems_version: 3.2.32
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: Add support for PostgreSQL's SEQUENCE on ActiveRecord migrations
|