scenic-oracle_adapter 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +41 -0
- data/.travis/oracle/download.sh +14 -0
- data/.travis/oracle/install.sh +33 -0
- data/.travis/setup_accounts.sh +14 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/test +6 -0
- data/lib/scenic/adapters/oracle.rb +76 -0
- data/lib/scenic/adapters/oracle/index.rb +18 -0
- data/lib/scenic/adapters/oracle/index_reapplication.rb +56 -0
- data/lib/scenic/adapters/oracle/indexes.rb +53 -0
- data/lib/scenic/adapters/oracle/railtie.rb +16 -0
- data/lib/scenic/oracle_adapter.rb +12 -0
- data/lib/scenic/oracle_adapter/version.rb +7 -0
- data/scenic-oracle_adapter.gemspec +33 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9409f3d5fb8a10fc6fed5fcd1501d0034ad2fa4a383733b1ff9a6818660576ff
|
4
|
+
data.tar.gz: 42256bb731d54eb934e7dd7cbc7abe4ef353f401e7c7b222cda5b30fd6a885b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c8486a41a221db67a984b06f5dfe9c754019f5c759bc540f47d5932991c97982fe9bb80fe20157a12854c51fa9f0e149a6956990ab2a13dd3b5a2b90b3106376
|
7
|
+
data.tar.gz: 583843437bf27efafc5bf84e1cff91b5ca23b3e4f0b169fc53ceaef8ab8dd31d5214bb7ead2e1ca0103edcf5e1120a187a810961ec1250c3f18161e393653e92
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
dist: trusty
|
3
|
+
sudo: required
|
4
|
+
language: ruby
|
5
|
+
cache: bundler
|
6
|
+
rvm:
|
7
|
+
- 2.3
|
8
|
+
- 2.4
|
9
|
+
- 2.5
|
10
|
+
|
11
|
+
env:
|
12
|
+
global:
|
13
|
+
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
|
14
|
+
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
|
15
|
+
- TNS_ADMIN=$ORACLE_HOME/network/admin
|
16
|
+
- NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
17
|
+
- ORACLE_BASE=/u01/app/oracle
|
18
|
+
- LD_LIBRARY_PATH=$ORACLE_HOME/lib
|
19
|
+
- PATH=$PATH:$ORACLE_HOME/jdbc/lib
|
20
|
+
- DATABASE_VERSION=11.2.0.1
|
21
|
+
- ORACLE_SID=XE
|
22
|
+
- DATABASE_NAME=XE
|
23
|
+
|
24
|
+
before_install:
|
25
|
+
- chmod +x .travis/oracle/download.sh
|
26
|
+
- chmod +x .travis/oracle/install.sh
|
27
|
+
- chmod +x .travis/setup_accounts.sh
|
28
|
+
- gem install bundler -v 1.16.5
|
29
|
+
|
30
|
+
install:
|
31
|
+
- .travis/oracle/download.sh
|
32
|
+
- .travis/oracle/install.sh
|
33
|
+
- .travis/setup_accounts.sh
|
34
|
+
- bundle install
|
35
|
+
|
36
|
+
jobs:
|
37
|
+
include:
|
38
|
+
- stage: Static analysis
|
39
|
+
script: bundle exec rubocop lib
|
40
|
+
- stage: Test
|
41
|
+
script: bundle exec rspec
|
@@ -0,0 +1,14 @@
|
|
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}"
|
@@ -0,0 +1,33 @@
|
|
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
|
+
|
26
|
+
sudo usermod -aG dba $USER
|
27
|
+
|
28
|
+
( echo ; echo ; echo travis ; echo travis ; echo n ) | sudo AWK='/usr/bin/awk' /etc/init.d/oracle-xe configure
|
29
|
+
|
30
|
+
"$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
|
31
|
+
CREATE USER $USER IDENTIFIED EXTERNALLY;
|
32
|
+
GRANT CONNECT, RESOURCE TO $USER;
|
33
|
+
SQL
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -ev
|
4
|
+
|
5
|
+
"$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
|
6
|
+
alter user sys identified by admin;
|
7
|
+
alter user system identified by admin;
|
8
|
+
alter database default tablespace USERS;
|
9
|
+
CREATE USER scenic_oracle_adapter IDENTIFIED BY scenic_oracle_adapter;
|
10
|
+
GRANT unlimited tablespace, create session, create table, create sequence,
|
11
|
+
create procedure, create trigger, create view, create materialized view,
|
12
|
+
create database link, create synonym, create type, ctxapp TO scenic_oracle_adapter;
|
13
|
+
exit
|
14
|
+
SQL
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ding0057@umn.edu. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Chris Dinger
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# scenic-oracle_adapter [![Build Status](https://travis-ci.org/cdinger/scenic-oracle_adapter.svg?branch=master)](https://travis-ci.org/cdinger/scenic-oracle_adapter)
|
2
|
+
|
3
|
+
An Oracle adapter for Thoughtbot's [scenic](https://github.com/thoughtbot/scenic) rubygem.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'scenic-oracle_adapter'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
You'll need to tell the scenic gem to use this adapter in an initializer:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# config/initializers/scenic.rb
|
21
|
+
|
22
|
+
Scenic.configure do |config|
|
23
|
+
config.database = Scenic::Adapters::Oracle.new
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` (or `rspec`) to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
By default, the test suite will attempt to connect to a local XE instance (see `spec/spec_helper.rb` for connection details).
|
32
|
+
You can override the database URL by supplying a value to the `DATABASE_URL` environment variable.
|
33
|
+
|
34
|
+
If you don't have a test Oracle database available, you can use [oracle-dev-box](https://github.com/cdinger/oracle-dev-box) to
|
35
|
+
run an XE instance in Vagrant.
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cdinger/scenic-oracle_adapter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
44
|
+
|
45
|
+
## Code of Conduct
|
46
|
+
|
47
|
+
Everyone interacting in the scenic-oracle_adapter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cdinger/scenic-oracle_adapter/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "scenic/oracle_adapter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/test
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "oracle/index_reapplication"
|
4
|
+
require_relative "oracle/indexes"
|
5
|
+
|
6
|
+
module Scenic
|
7
|
+
module Adapters
|
8
|
+
class Oracle
|
9
|
+
def initialize(connectable = ActiveRecord::Base)
|
10
|
+
@connectable = connectable
|
11
|
+
end
|
12
|
+
|
13
|
+
def views
|
14
|
+
all_views + all_mviews
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_view(name, definition)
|
18
|
+
execute("create view #{quote_table_name(name)} as #{definition}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def drop_view(name)
|
22
|
+
execute("drop view #{quote_table_name(name)}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def replace_view(name, definition)
|
26
|
+
execute("create or replace view #{quote_table_name(name)} as #{definition}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_view(name, definition)
|
30
|
+
drop_view(name)
|
31
|
+
create_view(name, definition)
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_materialized_view(name, definition)
|
35
|
+
execute("create materialized view #{quote_table_name(name)} as #{definition}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def update_materialized_view(name, definition)
|
39
|
+
IndexReapplication.new(connection: connection).on(name) do
|
40
|
+
drop_materialized_view(name)
|
41
|
+
create_materialized_view(name, definition)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def drop_materialized_view(name)
|
46
|
+
execute("drop materialized view #{quote_table_name(name)}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def refresh_materialized_view(name, concurrently: false)
|
50
|
+
atomic_refresh = concurrently.to_s.upcase
|
51
|
+
execute(<<~EOSQL)
|
52
|
+
begin
|
53
|
+
dbms_mview.refresh('#{name}', method => '?', atomic_refresh => #{atomic_refresh});
|
54
|
+
end;
|
55
|
+
EOSQL
|
56
|
+
end
|
57
|
+
|
58
|
+
delegate :connection, to: :@connectable
|
59
|
+
delegate :select_all, :execute, :quote_table_name, to: :connection
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def all_views
|
64
|
+
select_all("select lower(view_name) name, text definition from user_views").map do |view|
|
65
|
+
Scenic::View.new(name: view["name"], definition: view["definition"], materialized: false)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def all_mviews
|
70
|
+
select_all("select lower(mview_name) as name, query as definition from user_mviews").map do |view|
|
71
|
+
Scenic::View.new(name: view["name"], definition: view["definition"], materialized: true)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Scenic
|
4
|
+
module Adapters
|
5
|
+
class Oracle
|
6
|
+
class Index < Scenic::Index
|
7
|
+
attr_reader :columns
|
8
|
+
|
9
|
+
def initialize(object_name:, index_name:, columns:, definition:)
|
10
|
+
@object_name = object_name
|
11
|
+
@index_name = index_name
|
12
|
+
@columns = columns
|
13
|
+
@definition = definition
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Scenic
|
4
|
+
module Adapters
|
5
|
+
class Oracle
|
6
|
+
class IndexReapplication
|
7
|
+
def initialize(connection:, speaker: ActiveRecord::Migration)
|
8
|
+
@connection = connection
|
9
|
+
@speaker = speaker
|
10
|
+
end
|
11
|
+
|
12
|
+
def on(name)
|
13
|
+
indexes = Indexes.new(connection: connection).on(name)
|
14
|
+
|
15
|
+
yield
|
16
|
+
|
17
|
+
indexes.each(&method(:try_index_create))
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :connection, :speaker
|
23
|
+
|
24
|
+
def try_index_create(index)
|
25
|
+
if valid_index?(index)
|
26
|
+
if connection.execute(index.definition)
|
27
|
+
say "index '#{index.index_name}' on '#{index.object_name}' has been recreated"
|
28
|
+
end
|
29
|
+
else
|
30
|
+
say "index '#{index.index_name}' on '#{index.object_name}' is no longer valid and has been dropped."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def valid_index?(index)
|
35
|
+
object_columns = Set.new(object_columns(index.object_name))
|
36
|
+
index_columns = Set.new(index.columns)
|
37
|
+
|
38
|
+
index_columns.subset?(object_columns)
|
39
|
+
end
|
40
|
+
|
41
|
+
def object_columns(name)
|
42
|
+
connection.select_values(<<-EOSQL)
|
43
|
+
select lower(column_name)
|
44
|
+
from user_tab_cols
|
45
|
+
where table_name = '#{name}'
|
46
|
+
EOSQL
|
47
|
+
end
|
48
|
+
|
49
|
+
def say(message)
|
50
|
+
subitem = true
|
51
|
+
speaker.say(message, subitem)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "index"
|
4
|
+
|
5
|
+
module Scenic
|
6
|
+
module Adapters
|
7
|
+
class Oracle
|
8
|
+
class Indexes
|
9
|
+
def initialize(connection:)
|
10
|
+
@connection = connection
|
11
|
+
end
|
12
|
+
|
13
|
+
def on(name)
|
14
|
+
indexes_on(name).map(&method(:index_from_database))
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :connection
|
20
|
+
delegate :quote_table_name, to: :connection
|
21
|
+
|
22
|
+
def indexes_on(name)
|
23
|
+
connection.select_all(<<-EOSQL)
|
24
|
+
select
|
25
|
+
table_name as object_name,
|
26
|
+
index_name,
|
27
|
+
dbms_metadata.get_ddl('INDEX', index_name, table_owner) as definition
|
28
|
+
from user_indexes
|
29
|
+
where table_name = upper('#{name}')
|
30
|
+
EOSQL
|
31
|
+
end
|
32
|
+
|
33
|
+
def index_columns(index_name)
|
34
|
+
connection.select_values(<<-EOSQL)
|
35
|
+
select lower(column_name)
|
36
|
+
from user_ind_columns
|
37
|
+
where index_name = upper('#{index_name}')
|
38
|
+
order by column_position
|
39
|
+
EOSQL
|
40
|
+
end
|
41
|
+
|
42
|
+
def index_from_database(result)
|
43
|
+
Scenic::Adapters::Oracle::Index.new(
|
44
|
+
object_name: result["object_name"],
|
45
|
+
index_name: result["index_name"],
|
46
|
+
columns: index_columns(result["index_name"]),
|
47
|
+
definition: result["definition"]
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/railtie"
|
4
|
+
require "active_record/connection_adapters/oracle_enhanced_adapter"
|
5
|
+
|
6
|
+
module Scenic
|
7
|
+
module Adapters
|
8
|
+
class Oracle
|
9
|
+
class Railtie < Rails::Railtie
|
10
|
+
ActiveSupport.on_load(:active_record) do
|
11
|
+
ActiveRecord::ConnectionAdapters::OracleEnhanced::SchemaDumper.prepend Scenic::SchemaDumper
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_record"
|
4
|
+
require "scenic"
|
5
|
+
require "scenic/oracle_adapter/version"
|
6
|
+
require "scenic/adapters/oracle"
|
7
|
+
require "scenic/adapters/oracle/railtie" if defined?(Rails)
|
8
|
+
|
9
|
+
module Scenic
|
10
|
+
module OracleAdapter
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "scenic/oracle_adapter/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "scenic-oracle_adapter"
|
8
|
+
spec.version = Scenic::OracleAdapter::VERSION
|
9
|
+
spec.authors = ["Chris Dinger"]
|
10
|
+
spec.email = ["chris@houseofding.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Oracle adapter for thoughtbot/scenic}
|
13
|
+
spec.homepage = "https://github.com/cdinger/scenic-oracle_adapter"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "scenic", "~> 1.4.1"
|
26
|
+
spec.add_dependency "activerecord-oracle_enhanced-adapter", ">= 1.5.0"
|
27
|
+
spec.add_dependency "ruby-oci8", "~> 2.2"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_development_dependency "rubocop", ">= 0.49.0"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scenic-oracle_adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Dinger
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: scenic
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.4.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord-oracle_enhanced-adapter
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-oci8
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.49.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.49.0
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- chris@houseofding.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".rubocop.yml"
|
121
|
+
- ".travis.yml"
|
122
|
+
- ".travis/oracle/download.sh"
|
123
|
+
- ".travis/oracle/install.sh"
|
124
|
+
- ".travis/setup_accounts.sh"
|
125
|
+
- CODE_OF_CONDUCT.md
|
126
|
+
- Gemfile
|
127
|
+
- LICENSE.txt
|
128
|
+
- README.md
|
129
|
+
- Rakefile
|
130
|
+
- bin/console
|
131
|
+
- bin/setup
|
132
|
+
- bin/test
|
133
|
+
- lib/scenic/adapters/oracle.rb
|
134
|
+
- lib/scenic/adapters/oracle/index.rb
|
135
|
+
- lib/scenic/adapters/oracle/index_reapplication.rb
|
136
|
+
- lib/scenic/adapters/oracle/indexes.rb
|
137
|
+
- lib/scenic/adapters/oracle/railtie.rb
|
138
|
+
- lib/scenic/oracle_adapter.rb
|
139
|
+
- lib/scenic/oracle_adapter/version.rb
|
140
|
+
- scenic-oracle_adapter.gemspec
|
141
|
+
homepage: https://github.com/cdinger/scenic-oracle_adapter
|
142
|
+
licenses:
|
143
|
+
- MIT
|
144
|
+
metadata: {}
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
requirements: []
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 2.7.6
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: Oracle adapter for thoughtbot/scenic
|
165
|
+
test_files: []
|