db_meta 0.6.2 → 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 +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/cd.yml +46 -0
- data/.github/workflows/ci.yml +65 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile.lock +45 -37
- data/README.md +12 -1
- data/Rakefile +2 -1
- data/db_meta.gemspec +4 -3
- data/lib/db_meta/oracle/base.rb +1 -1
- data/lib/db_meta/oracle/helper.rb +1 -3
- data/lib/db_meta/oracle/types/column.rb +14 -17
- data/lib/db_meta/oracle/types/constraint.rb +15 -15
- data/lib/db_meta/oracle/types/database_link.rb +2 -1
- data/lib/db_meta/oracle/types/function.rb +3 -2
- data/lib/db_meta/oracle/types/grant.rb +3 -1
- data/lib/db_meta/oracle/types/index.rb +3 -2
- data/lib/db_meta/oracle/types/materialized_view.rb +1 -1
- data/lib/db_meta/oracle/types/procedure.rb +3 -2
- data/lib/db_meta/oracle/types/sequence.rb +6 -5
- data/lib/db_meta/oracle/types/synonym.rb +2 -1
- data/lib/db_meta/oracle/types/table.rb +8 -8
- data/lib/db_meta/oracle/types/table_data_collection.rb +17 -17
- data/lib/db_meta/oracle/types/trigger.rb +9 -8
- data/lib/db_meta/version.rb +1 -1
- metadata +30 -17
- data/.travis/oracle/download.sh +0 -14
- data/.travis/oracle/install.sh +0 -32
- data/.travis/setup_accounts.sh +0 -8
- data/.travis.yml +0 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50da1c6c39b57c147425e4983c1a43f3c7eb1e3273ad2ea7d1357e3b86092612
|
|
4
|
+
data.tar.gz: b809cad32b8316b442ccfa6ed0dfa4d56c862ed8fced2f56a19c2e2ec7befa11
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 99f55bbd8d9454b0e259273a750af9a945c3a19c3a8c874d09aabfe6e5a2367e1e67f74ac33ce7b09db08aa745a022bfb67a0a88c2b6dc90376c9d35f4f8039f
|
|
7
|
+
data.tar.gz: f904eba74c746851cb576bd71df26265e245d7128debccc3a199bb6371abbd996a4e0c1508b8760d07eaf8fa79afc92c487e99ae448e6280bf2ea33b9caeeb62
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: cd
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
env:
|
|
11
|
+
ORACLE_HOME: /opt/instantclient_21_7
|
|
12
|
+
LD_LIBRARY_PATH: /opt/instantclient_21_7
|
|
13
|
+
OCI_DIR: /opt/instantclient_21_7
|
|
14
|
+
NLS_LANG: AMERICAN_AMERICA.AL32UTF8
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout current code
|
|
18
|
+
uses: actions/checkout@v3
|
|
19
|
+
|
|
20
|
+
- name: Install Oracle instant client
|
|
21
|
+
run: |
|
|
22
|
+
mkdir -p /opt && cd /opt
|
|
23
|
+
curl https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basic-linux.x64-21.7.0.0.0dbru.zip --output instantclient.zip
|
|
24
|
+
curl https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-sdk-linux.x64-21.7.0.0.0dbru.zip --output instantclient_sdk.zip
|
|
25
|
+
unzip instantclient.zip
|
|
26
|
+
unzip instantclient_sdk.zip
|
|
27
|
+
|
|
28
|
+
- name: Set up Ruby
|
|
29
|
+
uses: ruby/setup-ruby@v1
|
|
30
|
+
with:
|
|
31
|
+
ruby-version: '3.1'
|
|
32
|
+
bundler: latest
|
|
33
|
+
bundler-cache: true
|
|
34
|
+
cache-version: 1
|
|
35
|
+
|
|
36
|
+
- name: Push to Rubygems
|
|
37
|
+
env:
|
|
38
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
39
|
+
run: |
|
|
40
|
+
git config --global user.email "thomas.steiner@ikey.ch"
|
|
41
|
+
git config --global user.name "thomis"
|
|
42
|
+
mkdir ~/.gem
|
|
43
|
+
echo -e "---\n:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials
|
|
44
|
+
chmod 600 ~/.gem/credentials
|
|
45
|
+
bundle exec rake release
|
|
46
|
+
rm ~/.gem/credentials
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- "*"
|
|
7
|
+
|
|
8
|
+
pull_request:
|
|
9
|
+
branches:
|
|
10
|
+
- "*"
|
|
11
|
+
|
|
12
|
+
schedule:
|
|
13
|
+
- cron: 0 2 * * 1,3,5,6
|
|
14
|
+
|
|
15
|
+
# Allows you to run this workflow manually from the Actions tab
|
|
16
|
+
workflow_dispatch:
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
env:
|
|
22
|
+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
|
23
|
+
ORACLE_HOME: /opt/instantclient_21_7
|
|
24
|
+
LD_LIBRARY_PATH: /opt/instantclient_21_7
|
|
25
|
+
OCI_DIR: /opt/instantclient_21_7
|
|
26
|
+
NLS_LANG: AMERICAN_AMERICA.AL32UTF8
|
|
27
|
+
|
|
28
|
+
strategy:
|
|
29
|
+
fail-fast: false
|
|
30
|
+
matrix:
|
|
31
|
+
ruby: [ '3.2', '3.1', '3.0', '2.7', '2.6']
|
|
32
|
+
|
|
33
|
+
name: Ruby ${{ matrix.ruby }}
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v3
|
|
36
|
+
|
|
37
|
+
- name: Install Oracle instant client
|
|
38
|
+
run: |
|
|
39
|
+
mkdir -p /opt && cd /opt
|
|
40
|
+
curl https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basic-linux.x64-21.7.0.0.0dbru.zip --output instantclient.zip
|
|
41
|
+
curl https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-sdk-linux.x64-21.7.0.0.0dbru.zip --output instantclient_sdk.zip
|
|
42
|
+
unzip instantclient.zip
|
|
43
|
+
unzip instantclient_sdk.zip
|
|
44
|
+
|
|
45
|
+
- name: Set up Ruby
|
|
46
|
+
uses: ruby/setup-ruby@v1
|
|
47
|
+
with:
|
|
48
|
+
ruby-version: ${{ matrix.ruby }}
|
|
49
|
+
bundler: latest
|
|
50
|
+
bundler-cache: true
|
|
51
|
+
cache-version: 3
|
|
52
|
+
|
|
53
|
+
- name: Code Climate setup test reporter
|
|
54
|
+
run: |
|
|
55
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
|
56
|
+
chmod +x ./cc-test-reporter
|
|
57
|
+
./cc-test-reporter before-build
|
|
58
|
+
|
|
59
|
+
- name: Run default task
|
|
60
|
+
run: |
|
|
61
|
+
bundle exec rake
|
|
62
|
+
|
|
63
|
+
- name: Code Climate publish test coverage
|
|
64
|
+
run: |
|
|
65
|
+
./cc-test-reporter after-build
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
## [0.7.0] - 2022-11-20
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
- Use GitHub actions
|
|
5
|
+
- Use Ruby style guide and linter
|
|
6
|
+
- Use Dependabot to keep dependencies up to date
|
|
7
|
+
- Use test coverage
|
|
8
|
+
- Have more rspec tests
|
|
9
|
+
- Update dependencies
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Remove travis integration
|
|
13
|
+
- Update depenencies
|
|
14
|
+
- Fix rspec tests
|
|
15
|
+
|
|
1
16
|
## [0.6.2] - 2021-06-29
|
|
2
17
|
|
|
3
18
|
### Changed
|
|
4
19
|
- Fix check when column.comment is nil
|
|
5
20
|
|
|
21
|
+
## [0.6.2] - 2021-07-21
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Update ruby versions to test
|
|
25
|
+
|
|
6
26
|
## [0.6.1] - 2021-05-01
|
|
7
27
|
|
|
8
28
|
### Changed
|
data/Gemfile.lock
CHANGED
|
@@ -1,67 +1,75 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
db_meta (0.
|
|
4
|
+
db_meta (0.7.0)
|
|
5
5
|
ruby-oci8 (~> 2.2)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
10
|
ast (2.4.2)
|
|
11
|
-
diff-lcs (1.
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
diff-lcs (1.5.0)
|
|
12
|
+
docile (1.4.0)
|
|
13
|
+
json (2.6.2)
|
|
14
|
+
parallel (1.22.1)
|
|
15
|
+
parser (3.1.2.1)
|
|
14
16
|
ast (~> 2.4.1)
|
|
15
|
-
rainbow (3.
|
|
16
|
-
rake (13.0.
|
|
17
|
-
regexp_parser (2.
|
|
17
|
+
rainbow (3.1.1)
|
|
18
|
+
rake (13.0.6)
|
|
19
|
+
regexp_parser (2.6.1)
|
|
18
20
|
rexml (3.2.5)
|
|
19
|
-
rspec (3.
|
|
20
|
-
rspec-core (~> 3.
|
|
21
|
-
rspec-expectations (~> 3.
|
|
22
|
-
rspec-mocks (~> 3.
|
|
23
|
-
rspec-core (3.
|
|
24
|
-
rspec-support (~> 3.
|
|
25
|
-
rspec-expectations (3.
|
|
21
|
+
rspec (3.12.0)
|
|
22
|
+
rspec-core (~> 3.12.0)
|
|
23
|
+
rspec-expectations (~> 3.12.0)
|
|
24
|
+
rspec-mocks (~> 3.12.0)
|
|
25
|
+
rspec-core (3.12.0)
|
|
26
|
+
rspec-support (~> 3.12.0)
|
|
27
|
+
rspec-expectations (3.12.0)
|
|
26
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
27
|
-
rspec-support (~> 3.
|
|
28
|
-
rspec-mocks (3.
|
|
29
|
+
rspec-support (~> 3.12.0)
|
|
30
|
+
rspec-mocks (3.12.0)
|
|
29
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
30
|
-
rspec-support (~> 3.
|
|
31
|
-
rspec-support (3.
|
|
32
|
-
rubocop (1.
|
|
32
|
+
rspec-support (~> 3.12.0)
|
|
33
|
+
rspec-support (3.12.0)
|
|
34
|
+
rubocop (1.39.0)
|
|
35
|
+
json (~> 2.3)
|
|
33
36
|
parallel (~> 1.10)
|
|
34
|
-
parser (>= 3.
|
|
37
|
+
parser (>= 3.1.2.1)
|
|
35
38
|
rainbow (>= 2.2.2, < 4.0)
|
|
36
39
|
regexp_parser (>= 1.8, < 3.0)
|
|
37
|
-
rexml
|
|
38
|
-
rubocop-ast (>= 1.
|
|
40
|
+
rexml (>= 3.2.5, < 4.0)
|
|
41
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
|
39
42
|
ruby-progressbar (~> 1.7)
|
|
40
43
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
41
|
-
rubocop-ast (1.
|
|
42
|
-
parser (>=
|
|
43
|
-
rubocop-performance (1.
|
|
44
|
-
rubocop (>=
|
|
44
|
+
rubocop-ast (1.23.0)
|
|
45
|
+
parser (>= 3.1.1.0)
|
|
46
|
+
rubocop-performance (1.15.0)
|
|
47
|
+
rubocop (>= 1.7.0, < 2.0)
|
|
45
48
|
rubocop-ast (>= 0.4.0)
|
|
46
|
-
ruby-oci8 (2.2.
|
|
49
|
+
ruby-oci8 (2.2.11)
|
|
47
50
|
ruby-progressbar (1.11.0)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
simplecov (0.21.2)
|
|
52
|
+
docile (~> 1.1)
|
|
53
|
+
simplecov-html (~> 0.11)
|
|
54
|
+
simplecov_json_formatter (~> 0.1)
|
|
55
|
+
simplecov-html (0.12.3)
|
|
56
|
+
simplecov_json_formatter (0.1.4)
|
|
57
|
+
standard (1.18.0)
|
|
58
|
+
rubocop (= 1.39.0)
|
|
59
|
+
rubocop-performance (= 1.15.0)
|
|
60
|
+
unicode-display_width (2.3.0)
|
|
54
61
|
|
|
55
62
|
PLATFORMS
|
|
56
63
|
ruby
|
|
57
64
|
x86_64-darwin-18
|
|
58
65
|
|
|
59
66
|
DEPENDENCIES
|
|
60
|
-
bundler (~> 2.
|
|
67
|
+
bundler (~> 2.3)
|
|
61
68
|
db_meta!
|
|
62
69
|
rake (~> 13.0)
|
|
63
|
-
rspec (~> 3.
|
|
64
|
-
|
|
70
|
+
rspec (~> 3.12)
|
|
71
|
+
simplecov (~> 0.21)
|
|
72
|
+
standard (~> 1.18)
|
|
65
73
|
|
|
66
74
|
BUNDLED WITH
|
|
67
|
-
2.
|
|
75
|
+
2.3.19
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
[](https://badge.fury.io/rb/db_meta)
|
|
2
|
-
[](https://codeclimate.com/github/thomis/db_meta/maintainability)
|
|
3
|
+
[](https://codeclimate.com/github/thomis/db_meta/test_coverage)
|
|
4
|
+
[](https://github.com/thomis/db_meta/actions/workflows/ci.yml)
|
|
3
5
|
|
|
4
6
|
# Welcome to db_meta
|
|
5
7
|
Database meta and core data extraction.
|
|
@@ -44,6 +46,15 @@ meta.extract
|
|
|
44
46
|
- Function based Indexes
|
|
45
47
|
- more to come...
|
|
46
48
|
|
|
49
|
+
## Supported Ruby Versions
|
|
50
|
+
|
|
51
|
+
Currently supported and tested ruby versions are:
|
|
52
|
+
|
|
53
|
+
- 3.1
|
|
54
|
+
- 3.0
|
|
55
|
+
- 2.7
|
|
56
|
+
- 2.6 (EOL 31 Mar 2022)
|
|
57
|
+
|
|
47
58
|
## Planned Features
|
|
48
59
|
- Storage and tablespace clause
|
|
49
60
|
|
data/Rakefile
CHANGED
data/db_meta.gemspec
CHANGED
|
@@ -18,10 +18,11 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
19
|
spec.require_paths = ["lib"]
|
|
20
20
|
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 2.
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.3"
|
|
22
22
|
spec.add_development_dependency "rake", "~> 13.0"
|
|
23
|
-
spec.add_development_dependency "rspec", "~> 3.
|
|
24
|
-
spec.add_development_dependency "
|
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.12"
|
|
24
|
+
spec.add_development_dependency "standard", "~> 1.18"
|
|
25
|
+
spec.add_development_dependency "simplecov", "~> 0.21"
|
|
25
26
|
|
|
26
27
|
spec.add_dependency "ruby-oci8", "~> 2.2"
|
|
27
28
|
end
|
data/lib/db_meta/oracle/base.rb
CHANGED
|
@@ -31,7 +31,7 @@ module DbMeta
|
|
|
31
31
|
|
|
32
32
|
@extract_type = :default # :default, :embedded, :merged
|
|
33
33
|
|
|
34
|
-
@system_object = @name
|
|
34
|
+
@system_object = /\$/i.match?(@name) # true if there is a '$' in the object name
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def fetch
|
|
@@ -12,9 +12,7 @@ module DbMeta
|
|
|
12
12
|
|
|
13
13
|
def write_buffer_to_file(buffer, file)
|
|
14
14
|
buffer = buffer.join("\n") if buffer.is_a?(Array)
|
|
15
|
-
File.
|
|
16
|
-
output.write(buffer)
|
|
17
|
-
end
|
|
15
|
+
File.write(file.downcase.tr(" ", "_"), buffer)
|
|
18
16
|
end
|
|
19
17
|
|
|
20
18
|
def remove_folder(folder)
|
|
@@ -3,9 +3,6 @@ module DbMeta
|
|
|
3
3
|
class Column
|
|
4
4
|
attr_accessor :name, :type, :data_length, :data_precision, :data_scale, :nullable, :data_default, :comment
|
|
5
5
|
|
|
6
|
-
def initialize(args = {})
|
|
7
|
-
end
|
|
8
|
-
|
|
9
6
|
def extract
|
|
10
7
|
buffer = ("%-30s" % @name).to_s
|
|
11
8
|
buffer << " #{convert_type}"
|
|
@@ -47,20 +44,20 @@ module DbMeta
|
|
|
47
44
|
|
|
48
45
|
def convert_type
|
|
49
46
|
case @type
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
when "FLOAT"
|
|
48
|
+
buffer = @type.to_s
|
|
49
|
+
buffer << "(#{@data_precision})" unless @data_precision == 0
|
|
50
|
+
buffer
|
|
51
|
+
when "NUMBER"
|
|
52
|
+
buffer = @type.to_s
|
|
53
|
+
buffer << "(#{@data_precision}" unless @data_precision == 0
|
|
54
|
+
buffer << ",#{@data_scale}" unless @data_scale == 0
|
|
55
|
+
buffer << ")" if buffer.include?("(")
|
|
56
|
+
buffer
|
|
57
|
+
when /CHAR|RAW/
|
|
58
|
+
"#{@type}(#{@data_length} BYTE)"
|
|
59
|
+
else
|
|
60
|
+
@type
|
|
64
61
|
end
|
|
65
62
|
end
|
|
66
63
|
end
|
|
@@ -46,13 +46,13 @@ module DbMeta
|
|
|
46
46
|
buffer << " CONSTRAINT #{@name}"
|
|
47
47
|
|
|
48
48
|
case @constraint_type
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
when "CHECK"
|
|
50
|
+
buffer << " #{@constraint_type} (#{@search_condition})"
|
|
51
|
+
when "FOREIGN KEY"
|
|
52
|
+
buffer << " #{@constraint_type} (#{@columns.join(", ")})"
|
|
53
|
+
buffer << " REFERENCES #{@referential_constraint.table_name} (#{@referential_constraint.columns.join(", ")})"
|
|
54
|
+
else
|
|
55
|
+
buffer << " #{@constraint_type} (#{@columns.join(", ")})"
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
buffer << " ON DELETE CASCADE" if @delete_rule == "CASCADE"
|
|
@@ -73,14 +73,14 @@ module DbMeta
|
|
|
73
73
|
|
|
74
74
|
def translate_constraint_type(type)
|
|
75
75
|
case type
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
when "P"
|
|
77
|
+
"PRIMARY KEY"
|
|
78
|
+
when "U"
|
|
79
|
+
"UNIQUE"
|
|
80
|
+
when "C"
|
|
81
|
+
"CHECK"
|
|
82
|
+
when "R"
|
|
83
|
+
"FOREIGN KEY"
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
end
|
|
@@ -6,7 +6,8 @@ module DbMeta
|
|
|
6
6
|
attr_reader :username, :password, :host
|
|
7
7
|
|
|
8
8
|
def fetch(args = {})
|
|
9
|
-
|
|
9
|
+
connection_class = args[:connection_class] || Connection
|
|
10
|
+
connection = connection_class.instance.get
|
|
10
11
|
cursor = connection.exec("select username, password, host from user_db_links where db_link = '#{@name}'")
|
|
11
12
|
while (row = cursor.fetch)
|
|
12
13
|
@username = row[0].to_s
|
|
@@ -5,9 +5,10 @@ module DbMeta
|
|
|
5
5
|
|
|
6
6
|
attr_reader :source
|
|
7
7
|
|
|
8
|
-
def fetch
|
|
8
|
+
def fetch(args = {})
|
|
9
9
|
@source = ""
|
|
10
|
-
|
|
10
|
+
connection_class = args[:connection_class] || Connection
|
|
11
|
+
connection = connection_class.instance.get
|
|
11
12
|
cursor = connection.exec("select text from user_source where type = 'FUNCTION' and name = '#{@name}' order by line")
|
|
12
13
|
while (row = cursor.fetch)
|
|
13
14
|
@source << row[0].to_s
|
|
@@ -11,8 +11,10 @@ module DbMeta
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def fetch(args = {})
|
|
14
|
+
connection_class = args[:connection_class] || Connection
|
|
14
15
|
# definition is comma seperated in the name to prevent re-fetching table for every grant
|
|
15
16
|
@grantee, @owner, @table_name, @grantor, @privilege, @grantable = @name.split(",")
|
|
17
|
+
@external_grant = @grantor != connection_class.instance.username.upcase
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def extract(args = {})
|
|
@@ -33,7 +35,7 @@ module DbMeta
|
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
def external_grant?
|
|
36
|
-
@
|
|
38
|
+
@external_grant
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
def sort_value
|
|
@@ -13,7 +13,8 @@ module DbMeta
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def fetch(args = {})
|
|
16
|
-
|
|
16
|
+
connection_class = args[:connection_class] || Connection
|
|
17
|
+
connection = connection_class.instance.get
|
|
17
18
|
cursor = connection.exec("select index_type, table_name, uniqueness, tablespace_name from user_indexes where index_name = '#{@name}'")
|
|
18
19
|
while (row = cursor.fetch)
|
|
19
20
|
@index_type = row[0].to_s
|
|
@@ -42,7 +43,7 @@ module DbMeta
|
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def extract(args = {})
|
|
45
|
-
"CREATE#{@uniqueness == "UNIQUE" ? " UNIQUE" : nil} INDEX #{@name} ON #{@table_name}(#{@columns.join(", ")});"
|
|
46
|
+
"CREATE#{(@uniqueness == "UNIQUE") ? " UNIQUE" : nil} INDEX #{@name} ON #{@table_name}(#{@columns.join(", ")});"
|
|
46
47
|
end
|
|
47
48
|
end
|
|
48
49
|
end
|
|
@@ -14,7 +14,7 @@ module DbMeta
|
|
|
14
14
|
@build_mode = item["BUILD_MODE"]
|
|
15
15
|
@refresh_mode = item["REFRESH_MODE"]
|
|
16
16
|
@refresh_method = item["REFRESH_METHOD"]
|
|
17
|
-
@rewrite_enabled = item["REWRITE_ENABLED"] == "Y" ? "ENABLE" : "DISABLE"
|
|
17
|
+
@rewrite_enabled = (item["REWRITE_ENABLED"] == "Y") ? "ENABLE" : "DISABLE"
|
|
18
18
|
end
|
|
19
19
|
cursor.close
|
|
20
20
|
|
|
@@ -5,9 +5,10 @@ module DbMeta
|
|
|
5
5
|
|
|
6
6
|
attr_reader :source
|
|
7
7
|
|
|
8
|
-
def fetch
|
|
8
|
+
def fetch(args = {})
|
|
9
9
|
@source = ""
|
|
10
|
-
|
|
10
|
+
connection_class = args[:connection_class] || Connection
|
|
11
|
+
connection = connection_class.instance.get
|
|
11
12
|
cursor = connection.exec("select text from user_source where type = 'PROCEDURE' and name = '#{@name}' order by line")
|
|
12
13
|
while (row = cursor.fetch)
|
|
13
14
|
@source << row[0].to_s
|
|
@@ -5,8 +5,9 @@ module DbMeta
|
|
|
5
5
|
|
|
6
6
|
attr_reader :min_value, :max_value, :increment_by, :cycle_flag, :order_flag, :cache_size, :last_number
|
|
7
7
|
|
|
8
|
-
def fetch
|
|
9
|
-
|
|
8
|
+
def fetch(args = {})
|
|
9
|
+
connection_class = args[:connection_class] || Connection
|
|
10
|
+
connection = connection_class.instance.get
|
|
10
11
|
cursor = connection.exec("select to_char(min_value), to_char(max_value), to_char(increment_by), cycle_flag, order_flag, to_char(cache_size), to_char(last_number) from user_sequences where sequence_name = '#{@name}'")
|
|
11
12
|
while (row = cursor.fetch)
|
|
12
13
|
@min_value = row[0].to_i
|
|
@@ -28,9 +29,9 @@ module DbMeta
|
|
|
28
29
|
buffer << " START WITH #{@last_number}"
|
|
29
30
|
buffer << " MAXVALUE #{@max_value}"
|
|
30
31
|
buffer << " MINVALUE #{@min_value}"
|
|
31
|
-
buffer << (@cycle_flag == "N" ? " NOCYCLE" : " CYCLE")
|
|
32
|
-
buffer << (@cache_size == 0 ? " NOCACHE" : " CACHE #{@cache_size}")
|
|
33
|
-
buffer << (@order_flag == "N" ? " NOORDER" : " ORDER")
|
|
32
|
+
buffer << ((@cycle_flag == "N") ? " NOCYCLE" : " CYCLE")
|
|
33
|
+
buffer << ((@cache_size == 0) ? " NOCACHE" : " CACHE #{@cache_size}")
|
|
34
|
+
buffer << ((@order_flag == "N") ? " NOORDER" : " ORDER")
|
|
34
35
|
buffer << ";"
|
|
35
36
|
buffer << nil
|
|
36
37
|
buffer.join("\n")
|
|
@@ -12,7 +12,8 @@ module DbMeta
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def fetch(args = {})
|
|
15
|
-
|
|
15
|
+
connection_class = args[:connection_class] || Connection
|
|
16
|
+
connection = connection_class.instance.get
|
|
16
17
|
cursor = connection.exec("select table_owner, table_name, db_link from user_synonyms where synonym_name = '#{@name}'")
|
|
17
18
|
while (row = cursor.fetch)
|
|
18
19
|
@table_owner = row[0].to_s
|
|
@@ -30,8 +30,8 @@ module DbMeta
|
|
|
30
30
|
connection = Connection.instance.get
|
|
31
31
|
cursor = connection.exec("select temporary, cache, iot_type, duration from user_tables where table_name = '#{@name}'")
|
|
32
32
|
while (row = cursor.fetch)
|
|
33
|
-
@temporary = row[0].to_s.strip == "Y" ? "GLOBAL TEMPORARY" : nil
|
|
34
|
-
@cache = row[1].to_s.strip == "Y" ? "CACHE" : "NOCACHE"
|
|
33
|
+
@temporary = (row[0].to_s.strip == "Y") ? "GLOBAL TEMPORARY" : nil
|
|
34
|
+
@cache = (row[1].to_s.strip == "Y") ? "CACHE" : "NOCACHE"
|
|
35
35
|
@iot_type = row[2].to_s
|
|
36
36
|
@duration = row[3].to_s
|
|
37
37
|
end
|
|
@@ -130,12 +130,12 @@ module DbMeta
|
|
|
130
130
|
|
|
131
131
|
def translate_duration
|
|
132
132
|
case @duration
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
when "SYS$TRANSACTION"
|
|
134
|
+
"ON COMMIT DELETE ROWS"
|
|
135
|
+
when "SYS$SESSION"
|
|
136
|
+
"ON COMMIT PRESERVE ROWS"
|
|
137
|
+
else
|
|
138
|
+
"-- table duration definition [#{@duration}] is unknown and may need code adaptations"
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
end
|
|
@@ -68,23 +68,23 @@ module DbMeta
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
buffer << case name_type_map[key]
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
when /varchar|char/i
|
|
72
|
+
"'#{value.gsub("'", "''")}'"
|
|
73
|
+
when /clob/i
|
|
74
|
+
m = []
|
|
75
|
+
d = value.read
|
|
76
|
+
d.chars.each_slice(2000).map(&:join).each do |item|
|
|
77
|
+
m << "to_clob('#{item.gsub("'", "''").gsub(";", "' || CHR(59) || '")}')"
|
|
78
|
+
end
|
|
79
|
+
m.join(" || ")
|
|
80
|
+
when /date/i
|
|
81
|
+
"to_date('#{value.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')"
|
|
82
|
+
when /timestamp/i
|
|
83
|
+
"to_timezone('#{value.strftime("%Y-%m-%d %H:%M:%S %Z")}','YYYY-MM-DD HH24:MI:SS.FF TZD')"
|
|
84
|
+
when /raw/i
|
|
85
|
+
"'#{value}'"
|
|
86
|
+
else
|
|
87
|
+
value.to_s
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
|
|
@@ -11,8 +11,9 @@ module DbMeta
|
|
|
11
11
|
@extract_type = :embedded
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def fetch
|
|
15
|
-
|
|
14
|
+
def fetch(args = {})
|
|
15
|
+
connection_class = args[:connection_class] || Connection
|
|
16
|
+
connection = connection_class.instance.get
|
|
16
17
|
cursor = connection.exec("select trigger_type, triggering_event, table_name, referencing_names, description, trigger_body from user_triggers where trigger_name = '#{@name}'")
|
|
17
18
|
while (row = cursor.fetch)
|
|
18
19
|
@trigger_type = row[0].to_s
|
|
@@ -49,12 +50,12 @@ module DbMeta
|
|
|
49
50
|
@for_each = "FOR EACH ROW" if /each row/i.match?(@trigger_type)
|
|
50
51
|
|
|
51
52
|
case @trigger_type
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
when /before/i
|
|
54
|
+
@trigger_type = "BEFORE"
|
|
55
|
+
when /after/i
|
|
56
|
+
@trigger_type = "AFTER"
|
|
57
|
+
when /instead of/i
|
|
58
|
+
@for_each = "FOR EACH ROW"
|
|
58
59
|
end
|
|
59
60
|
end
|
|
60
61
|
end
|
data/lib/db_meta/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: db_meta
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomi
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-11-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.
|
|
19
|
+
version: '2.3'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2.
|
|
26
|
+
version: '2.3'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,28 +44,42 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3.
|
|
47
|
+
version: '3.12'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3.
|
|
54
|
+
version: '3.12'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: standard
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '1.
|
|
61
|
+
version: '1.18'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '1.
|
|
68
|
+
version: '1.18'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: simplecov
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0.21'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0.21'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: ruby-oci8
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -87,13 +101,12 @@ executables: []
|
|
|
87
101
|
extensions: []
|
|
88
102
|
extra_rdoc_files: []
|
|
89
103
|
files:
|
|
104
|
+
- ".github/dependabot.yml"
|
|
105
|
+
- ".github/workflows/cd.yml"
|
|
106
|
+
- ".github/workflows/ci.yml"
|
|
90
107
|
- ".gitignore"
|
|
91
108
|
- ".rspec"
|
|
92
109
|
- ".ruby-version"
|
|
93
|
-
- ".travis.yml"
|
|
94
|
-
- ".travis/oracle/download.sh"
|
|
95
|
-
- ".travis/oracle/install.sh"
|
|
96
|
-
- ".travis/setup_accounts.sh"
|
|
97
110
|
- CHANGELOG.md
|
|
98
111
|
- Gemfile
|
|
99
112
|
- Gemfile.lock
|
|
@@ -145,7 +158,7 @@ homepage: https://github.com/thomis/db_meta
|
|
|
145
158
|
licenses:
|
|
146
159
|
- Apache-2.0
|
|
147
160
|
metadata: {}
|
|
148
|
-
post_install_message:
|
|
161
|
+
post_install_message:
|
|
149
162
|
rdoc_options: []
|
|
150
163
|
require_paths:
|
|
151
164
|
- lib
|
|
@@ -160,8 +173,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
160
173
|
- !ruby/object:Gem::Version
|
|
161
174
|
version: '0'
|
|
162
175
|
requirements: []
|
|
163
|
-
rubygems_version: 3.
|
|
164
|
-
signing_key:
|
|
176
|
+
rubygems_version: 3.3.7
|
|
177
|
+
signing_key:
|
|
165
178
|
specification_version: 4
|
|
166
179
|
summary: Database meta and core data extraction
|
|
167
180
|
test_files: []
|
data/.travis/oracle/download.sh
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
cd "$(dirname "$(readlink -f "$0")")"
|
|
4
|
-
|
|
5
|
-
deb_file=oracle-xe_11.2.0-1.0_amd64.deb
|
|
6
|
-
|
|
7
|
-
git clone https://github.com/wnameless/docker-oracle-xe-11g.git
|
|
8
|
-
|
|
9
|
-
cd docker-oracle-xe-11g/assets &&
|
|
10
|
-
cat "${deb_file}aa" "${deb_file}ab" "${deb_file}ac" > "${deb_file}"
|
|
11
|
-
|
|
12
|
-
pwd
|
|
13
|
-
|
|
14
|
-
ls -lAh "${deb_file}"
|
data/.travis/oracle/install.sh
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
[ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
|
|
4
|
-
[ -n "$ORACLE_HOME" ] || { echo "Missing ORACLE_HOME environment variable!"; exit 1; }
|
|
5
|
-
|
|
6
|
-
cd "$(dirname "$(readlink -f "$0")")"
|
|
7
|
-
|
|
8
|
-
ORACLE_DEB=docker-oracle-xe-11g/assets/oracle-xe_11.2.0-1.0_amd64.deb
|
|
9
|
-
|
|
10
|
-
sudo apt-get -qq update
|
|
11
|
-
sudo apt-get --no-install-recommends -qq install bc libaio1
|
|
12
|
-
|
|
13
|
-
df -B1 /dev/shm | awk 'END { if ($1 != "shmfs" && $1 != "tmpfs" || $2 < 2147483648) exit 1 }' ||
|
|
14
|
-
( sudo rm -r /dev/shm && sudo mkdir /dev/shm && sudo mount -t tmpfs shmfs -o size=2G /dev/shm )
|
|
15
|
-
|
|
16
|
-
test -f /sbin/chkconfig ||
|
|
17
|
-
( echo '#!/bin/sh' | sudo tee /sbin/chkconfig > /dev/null && sudo chmod u+x /sbin/chkconfig )
|
|
18
|
-
|
|
19
|
-
test -d /var/lock/subsys || sudo mkdir /var/lock/subsys
|
|
20
|
-
|
|
21
|
-
sudo dpkg -i "${ORACLE_DEB}"
|
|
22
|
-
|
|
23
|
-
echo 'OS_AUTHENT_PREFIX=""' | sudo tee -a "$ORACLE_HOME/config/scripts/init.ora" > /dev/null
|
|
24
|
-
echo 'disk_asynch_io=false' | sudo tee -a "$ORACLE_HOME/config/scripts/init.ora" > /dev/null
|
|
25
|
-
sudo usermod -aG dba $USER
|
|
26
|
-
|
|
27
|
-
( echo ; echo ; echo travis ; echo travis ; echo n ) | sudo AWK='/usr/bin/awk' /etc/init.d/oracle-xe configure
|
|
28
|
-
|
|
29
|
-
"$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
|
|
30
|
-
CREATE USER $USER IDENTIFIED EXTERNALLY;
|
|
31
|
-
GRANT CONNECT, RESOURCE TO $USER;
|
|
32
|
-
SQL
|
data/.travis/setup_accounts.sh
DELETED
data/.travis.yml
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
sudo: required
|
|
2
|
-
|
|
3
|
-
env:
|
|
4
|
-
global:
|
|
5
|
-
- ORACLE_COOKIE=sqldev
|
|
6
|
-
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
|
|
7
|
-
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
|
|
8
|
-
- NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
|
9
|
-
- ORACLE_BASE=/u01/app/oracle
|
|
10
|
-
- LD_LIBRARY_PATH=$ORACLE_HOME/lib
|
|
11
|
-
- PATH=$PATH:$ORACLE_HOME/jdbc/lib
|
|
12
|
-
- DATABASE_VERSION=11.2.0.2
|
|
13
|
-
- ORACLE_SID=XE
|
|
14
|
-
- DATABASE_NAME=XE
|
|
15
|
-
- ORA_SDTZ='Europe/London' # Needed as a client parameter
|
|
16
|
-
- TZ='Europe/London' # Needed as a DB Server parameter
|
|
17
|
-
|
|
18
|
-
before_install:
|
|
19
|
-
- chmod +x .travis/oracle/download.sh
|
|
20
|
-
- chmod +x .travis/oracle/install.sh
|
|
21
|
-
- chmod +x .travis/setup_accounts.sh
|
|
22
|
-
- gem install bundler --version '~> 2.1.4'
|
|
23
|
-
|
|
24
|
-
install:
|
|
25
|
-
- .travis/oracle/download.sh
|
|
26
|
-
- .travis/oracle/install.sh
|
|
27
|
-
- .travis/setup_accounts.sh
|
|
28
|
-
- bundle install
|
|
29
|
-
|
|
30
|
-
language: ruby
|
|
31
|
-
rvm:
|
|
32
|
-
- 3.0.0
|
|
33
|
-
- 2.7.2
|
|
34
|
-
- 2.6.6
|
|
35
|
-
- 2.5.8
|