activerecord-dsql-adapter 0.1.3 → 0.1.5
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
- checksums.yaml.gz.sig +0 -0
- data/README.md +75 -0
- data/lib/active_record/connection_adapters/dsql/railtie.rb +13 -0
- data/lib/active_record/connection_adapters/dsql/schema_dumper.rb +15 -0
- data/lib/active_record/connection_adapters/dsql/schema_statements.rb +14 -0
- data/lib/active_record/connection_adapters/dsql_adapter.rb +17 -12
- data/lib/active_record/tasks/dsql_database_tasks.rb +30 -0
- data/lib/activerecord-dsql-adapter.rb +24 -1
- data.tar.gz.sig +0 -0
- metadata +23 -17
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bba333873c829af25ffcf9a57c9eac82af22672f9b23b8ad0e868b9f207da5ae
|
4
|
+
data.tar.gz: 2c958e61542f81683de0dc04bae5e0b8dde6002aa2128e8f4c1e4933063f27be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47cbd5b86957b9bc556ac3929ea2393d76363ffd0fa8ac7df96c9b8bbb2794ec5caf6c7d01c5d103b6440b2d1326fd7b37c648a7c765a4d40d5c3b4d9a3db3a6
|
7
|
+
data.tar.gz: 1038d78431011751fca28ecf41a9982061a1749833fe61efe8f1005d01cd09446faf8773d337cbb92bd7112bbf6d35e2d116ec5e03492c392859b609ef698553
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -35,6 +35,81 @@ dsql-example(dev)> ActiveRecord::Base.connection.execute("SELECT 1")
|
|
35
35
|
=> #<PG::Result:0x00000001238b39a8 status=PGRES_TUPLES_OK ntuples=1 nfields=1 cmd_tuples=1>
|
36
36
|
```
|
37
37
|
|
38
|
+
```
|
39
|
+
rails dbconsole -p
|
40
|
+
psql (14.13 (Homebrew), server 16.5)
|
41
|
+
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_128_GCM_SHA256, bits: 128, compression: off)
|
42
|
+
Type "help" for help.
|
43
|
+
|
44
|
+
[postgres] >
|
45
|
+
```
|
46
|
+
|
47
|
+
```
|
48
|
+
$ rails generate scaffold create_posts title:string body:text
|
49
|
+
invoke active_record
|
50
|
+
create db/migrate/20241204112954_create_posts.rb
|
51
|
+
create app/models/post.rb
|
52
|
+
invoke resource_route
|
53
|
+
route resources :posts
|
54
|
+
invoke scaffold_controller
|
55
|
+
create app/controllers/posts_controller.rb
|
56
|
+
invoke erb
|
57
|
+
create app/views/posts
|
58
|
+
create app/views/posts/index.html.erb
|
59
|
+
create app/views/posts/edit.html.erb
|
60
|
+
create app/views/posts/show.html.erb
|
61
|
+
create app/views/posts/new.html.erb
|
62
|
+
create app/views/posts/_form.html.erb
|
63
|
+
create app/views/posts/_post.html.erb
|
64
|
+
invoke resource_route
|
65
|
+
invoke helper
|
66
|
+
create app/helpers/posts_helper.rb
|
67
|
+
|
68
|
+
$ rails db:migrate
|
69
|
+
== 20241204112954 CreatePosts: migrating ======================================
|
70
|
+
-- create_table(:posts)
|
71
|
+
-> 0.3887s
|
72
|
+
== 20241204112954 CreatePosts: migrated (0.3889s) =============================
|
73
|
+
|
74
|
+
$ rails console
|
75
|
+
Loading development environment (Rails 7.2.2)
|
76
|
+
|
77
|
+
pry(main)> post = Post.create!(title: "Hello, world!")
|
78
|
+
TRANSACTION (218.9ms) BEGIN
|
79
|
+
Post Create (530.9ms) INSERT INTO "posts" ("title", "body", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["title", "Hello, world!"], ["body", nil], ["created_at", "2024-12-04 11:37:41.238422"], ["updated_at", "2024-12-04 11:37:41.238422"]]
|
80
|
+
TRANSACTION (276.7ms) COMMIT
|
81
|
+
=> #<Post:0x00000001267f30d8 id: "5b642ccc-c5e1-4d7c-828b-70fc107bf6e9", title: "Hello, world!", body: nil, created_at: "2024-12-04 11:37:41.238422000 +0000", updated_at: "2024-12-04 11:37:41.238422000 +0000">
|
82
|
+
|
83
|
+
pry(main)> post.update!(body: "Should probably write something...")
|
84
|
+
TRANSACTION (221.5ms) BEGIN
|
85
|
+
Post Update (503.8ms) UPDATE "posts" SET "body" = $1, "updated_at" = $2 WHERE "posts"."id" = $3 [["body", "Should probably write something..."], ["updated_at", "2024-12-04 11:37:54.659673"], ["id", "5b642ccc-c5e1-4d7c-828b-70fc107bf6e9"]]
|
86
|
+
TRANSACTION (258.7ms) COMMIT
|
87
|
+
=> true
|
88
|
+
|
89
|
+
pry(main)> post.destroy!
|
90
|
+
TRANSACTION (217.6ms) BEGIN
|
91
|
+
Post Destroy (439.5ms) DELETE FROM "posts" WHERE "posts"."id" = $1 [["id", "5b642ccc-c5e1-4d7c-828b-70fc107bf6e9"]]
|
92
|
+
TRANSACTION (230.3ms) COMMIT
|
93
|
+
=> #<Post:0x00000001267f30d8 id: "5b642ccc-c5e1-4d7c-828b-70fc107bf6e9", title: "Hello, world!", body: "Should probably write something...", created_at: "2024-12-04 11:37:41.238422000 +0000", updated_at: "2024-12-04 11:37:54.659673000 +0000">
|
94
|
+
```
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
# db/schema.rb
|
98
|
+
|
99
|
+
ActiveRecord::Schema[7.2].define(version: 2024_12_04_112954) do
|
100
|
+
create_table "posts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
101
|
+
t.string "title"
|
102
|
+
t.text "body"
|
103
|
+
t.datetime "created_at", null: false
|
104
|
+
t.datetime "updated_at", null: false
|
105
|
+
|
106
|
+
t.unique_constraint ["id"], name: "posts_id_key"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
111
|
+
DSQL does not support `CREATE DATABASE` so `db:create` and `db:drop` do not work. But `db:prepare` can load the schema for you.
|
112
|
+
|
38
113
|
## Development
|
39
114
|
|
40
115
|
After checking out the repo, run `script/setup` to install dependencies. You can also run `script/console` for an interactive prompt that will allow you to experiment.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module ConnectionAdapters
|
5
|
+
module DSQL
|
6
|
+
class Railtie < ::Rails::Railtie
|
7
|
+
rake_tasks do
|
8
|
+
ActiveRecord::Tasks::DatabaseTasks.register_task("dsql", "ActiveRecord::Tasks::DSQLDatabaseTasks")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module ConnectionAdapters
|
5
|
+
module DSQL
|
6
|
+
module SchemaStatements
|
7
|
+
def add_index_options(table_name, column_name, **options) # :nodoc:
|
8
|
+
options[:algorithm] = :async
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -7,17 +7,11 @@ require "active_record/connection_adapters/postgresql_adapter"
|
|
7
7
|
|
8
8
|
module ActiveRecord
|
9
9
|
module ConnectionAdapters
|
10
|
-
module DSQL
|
11
|
-
class Railtie < ::Rails::Railtie
|
12
|
-
rake_tasks do
|
13
|
-
ActiveRecord::DatabaseTasks.register_task("dsql", "ActiveRecord::Tasks::DSQLDatabaseTasks")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
10
|
class DSQLAdapter < PostgreSQLAdapter
|
19
11
|
ADAPTER_NAME = "DSQL"
|
20
12
|
|
13
|
+
include ActiveRecord::ConnectionAdapters::DSQL::SchemaStatements
|
14
|
+
|
21
15
|
class << self
|
22
16
|
def new_client(conn_params)
|
23
17
|
conn_params[:sslmode] ||= "require"
|
@@ -127,6 +121,18 @@ module ActiveRecord
|
|
127
121
|
false
|
128
122
|
end
|
129
123
|
|
124
|
+
def index_algorithms
|
125
|
+
{ async: "ASYNC" }
|
126
|
+
end
|
127
|
+
|
128
|
+
# Ignore DSQL sys schema.
|
129
|
+
#
|
130
|
+
# https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-systems-tables.html
|
131
|
+
#
|
132
|
+
def schema_names
|
133
|
+
super - ["sys"]
|
134
|
+
end
|
135
|
+
|
130
136
|
# DSQL creates a primary key index which INCLUDES all columns in the
|
131
137
|
# table. We use indnkeyatts to only take notice of key (not INCLUDE-ed)
|
132
138
|
# columns for the primary key.
|
@@ -149,11 +155,10 @@ module ActiveRecord
|
|
149
155
|
ORDER BY i.idx
|
150
156
|
SQL
|
151
157
|
end
|
152
|
-
end
|
153
|
-
end
|
154
158
|
|
155
|
-
|
156
|
-
|
159
|
+
def create_schema_dumper(options) # :nodoc:
|
160
|
+
DSQL::SchemaDumper.create(self, options)
|
161
|
+
end
|
157
162
|
end
|
158
163
|
end
|
159
164
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_record"
|
4
|
+
require "active_record/tasks/postgresql_database_tasks"
|
5
|
+
|
6
|
+
module ActiveRecord
|
7
|
+
module Tasks
|
8
|
+
class DSQLDatabaseTasks < PostgreSQLDatabaseTasks
|
9
|
+
def initialize(config)
|
10
|
+
config_hash = config.configuration_hash.dup
|
11
|
+
|
12
|
+
config_hash[:sslmode] ||= "require"
|
13
|
+
config_hash[:database] ||= "postgres"
|
14
|
+
config_hash[:username] ||= "admin"
|
15
|
+
|
16
|
+
config = ActiveRecord::DatabaseConfigurations::HashConfig.new(config.env_name, config.name, config_hash)
|
17
|
+
|
18
|
+
super(config)
|
19
|
+
end
|
20
|
+
|
21
|
+
def create(...)
|
22
|
+
fail "DSQL does not support CREATE DATABASE"
|
23
|
+
end
|
24
|
+
|
25
|
+
def drop(...)
|
26
|
+
fail "DSQL does not support DROP DATABASE"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,7 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "active_record"
|
4
4
|
|
5
5
|
ActiveSupport.on_load(:active_record) do
|
6
6
|
ActiveRecord::ConnectionAdapters.register("dsql", "ActiveRecord::ConnectionAdapters::DSQLAdapter", "active_record/connection_adapters/dsql_adapter")
|
7
7
|
end
|
8
|
+
|
9
|
+
module ActiveRecord
|
10
|
+
module ConnectionAdapters
|
11
|
+
module DSQL
|
12
|
+
extend ActiveSupport::Autoload
|
13
|
+
|
14
|
+
autoload :SchemaDumper
|
15
|
+
autoload :SchemaStatements
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ActiveRecord
|
21
|
+
module Tasks
|
22
|
+
extend ActiveSupport::Autoload
|
23
|
+
|
24
|
+
autoload :DSQLDatabaseTasks, "active_record/tasks/dsql_database_tasks"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if defined? Rails
|
29
|
+
require "active_record/connection_adapters/dsql/railtie"
|
30
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-dsql-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Cochran
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain:
|
11
10
|
- |
|
12
11
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
12
|
+
MIIDKDCCAhCgAwIBAgIBBDANBgkqhkiG9w0BAQsFADA6MQ0wCwYDVQQDDARzajI2
|
14
13
|
MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0y
|
15
|
-
|
14
|
+
NTA5MDEwNT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000000000 Z
|
32
31
|
dependencies:
|
33
32
|
- !ruby/object:Gem::Dependency
|
34
33
|
name: activerecord
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
36
35
|
requirements:
|
37
|
-
- - "
|
36
|
+
- - ">="
|
38
37
|
- !ruby/object:Gem::Version
|
39
38
|
version: 7.2.0
|
39
|
+
- - "<"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '9'
|
40
42
|
type: :runtime
|
41
43
|
prerelease: false
|
42
44
|
version_requirements: !ruby/object:Gem::Requirement
|
43
45
|
requirements:
|
44
|
-
- - "
|
46
|
+
- - ">="
|
45
47
|
- !ruby/object:Gem::Version
|
46
48
|
version: 7.2.0
|
49
|
+
- - "<"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '9'
|
47
52
|
- !ruby/object:Gem::Dependency
|
48
53
|
name: pg
|
49
54
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,7 +77,6 @@ dependencies:
|
|
72
77
|
- - ">="
|
73
78
|
- !ruby/object:Gem::Version
|
74
79
|
version: '0'
|
75
|
-
description:
|
76
80
|
email:
|
77
81
|
- sj26@sj26.com
|
78
82
|
executables: []
|
@@ -80,7 +84,11 @@ extensions: []
|
|
80
84
|
extra_rdoc_files: []
|
81
85
|
files:
|
82
86
|
- README.md
|
87
|
+
- lib/active_record/connection_adapters/dsql/railtie.rb
|
88
|
+
- lib/active_record/connection_adapters/dsql/schema_dumper.rb
|
89
|
+
- lib/active_record/connection_adapters/dsql/schema_statements.rb
|
83
90
|
- lib/active_record/connection_adapters/dsql_adapter.rb
|
91
|
+
- lib/active_record/tasks/dsql_database_tasks.rb
|
84
92
|
- lib/activerecord-dsql-adapter.rb
|
85
93
|
homepage: https://github.com/sj26/activerecord-dsql-adapter
|
86
94
|
licenses: []
|
@@ -88,7 +96,6 @@ metadata:
|
|
88
96
|
homepage_uri: https://github.com/sj26/activerecord-dsql-adapter
|
89
97
|
source_code_uri: https://github.com/sj26/activerecord-dsql-adapter
|
90
98
|
changelog_uri: https://github.com/sj26/activerecord-dsql-adapter/releases
|
91
|
-
post_install_message:
|
92
99
|
rdoc_options: []
|
93
100
|
require_paths:
|
94
101
|
- lib
|
@@ -103,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
110
|
- !ruby/object:Gem::Version
|
104
111
|
version: '0'
|
105
112
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
107
|
-
signing_key:
|
113
|
+
rubygems_version: 3.7.2
|
108
114
|
specification_version: 4
|
109
115
|
summary: ActiveRecord adapter for AWS Aurora DSQL (PostgreSQL)
|
110
116
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|