db_schema-reader-postgres 0.2.rc1 → 0.2.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/db_schema/reader/postgres/version.rb +1 -1
- data/lib/db_schema/reader/postgres.rb +12 -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: 990b8933a3902ce9f0887944ff69f1134741987e77f059b029d5e7642b539a0a
|
4
|
+
data.tar.gz: a30df58f848726ce34b9975dad5d46de6595e697188c6443cf494f9247c85359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 997f6d45571460252be0010a4e91a807b62ed3e957682867b98f5a49a23fdff364d4204b47eba6454e4c27d442b8afbe0d0f7430a14896ad8887678c295caec0
|
7
|
+
data.tar.gz: 7808d2a72bbc61df6d3a451d412bc0839147ca1255490ce81e40bca94c800dbe6153ebfb11200e89fcfe5cd0cee9ff1d301a71b1e1a75c0762cdae317eb3e573
|
@@ -5,6 +5,13 @@ require_relative 'postgres/version'
|
|
5
5
|
module DbSchema
|
6
6
|
module Reader
|
7
7
|
class Postgres
|
8
|
+
TABLES_QUERY = <<-SQL.freeze
|
9
|
+
SELECT table_name
|
10
|
+
FROM information_schema.tables
|
11
|
+
WHERE table_type = 'BASE TABLE'
|
12
|
+
AND table_schema = 'public'
|
13
|
+
SQL
|
14
|
+
|
8
15
|
COLUMNS_QUERY = <<-SQL.freeze
|
9
16
|
SELECT c.table_name,
|
10
17
|
c.column_name AS name,
|
@@ -115,7 +122,7 @@ SELECT extname
|
|
115
122
|
def read_tables
|
116
123
|
checks_data, foreign_keys_data = constraints_data
|
117
124
|
|
118
|
-
|
125
|
+
table_names.map do |table_name|
|
119
126
|
Table.new(
|
120
127
|
table_name.to_sym,
|
121
128
|
columns_data[table_name],
|
@@ -139,6 +146,10 @@ SELECT extname
|
|
139
146
|
end
|
140
147
|
|
141
148
|
private
|
149
|
+
def table_names
|
150
|
+
@table_names ||= connection[TABLES_QUERY].to_a.map { |row| row[:table_name] }
|
151
|
+
end
|
152
|
+
|
142
153
|
def columns_data
|
143
154
|
@columns_data ||= connection[COLUMNS_QUERY].to_a.group_by do |column|
|
144
155
|
column[:table_name]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_schema-reader-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vsevolod Romashov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|