Skip to content

Commit c36330f

Browse files
committed
tmp: check difference between versions
1 parent 11c2767 commit c36330f

File tree

5 files changed

+54
-7
lines changed

5 files changed

+54
-7
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ jobs:
8888
done
8989
cat ${{ github.workspace }}/setup.sql | cockroach sql --insecure
9090
- name: Test
91-
run: bundle exec rake test TESTOPTS='--profile=5'
91+
run: bundle exec rake test TESTOPTS='--profile=5' TEST_FILES=test/cases/reproduction_test.rb

bin/console

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ require "activerecord-cockroachdb-adapter"
1212
# structure_load(Post.connection_db_config, "awesome-file.sql")
1313
require "active_record/connection_adapters/cockroachdb/database_tasks"
1414

15+
DB_NAME = "ar_crdb_console"
16+
1517
schema_kind = ENV.fetch("SCHEMA_KIND", ENV.fetch("SCHEMA", "default"))
1618

17-
system("cockroach sql --insecure --host=localhost:26257 --execute='drop database if exists ar_crdb_console'",
19+
system("cockroach sql --insecure --host=localhost:26257 --execute='drop database if exists #{DB_NAME}'",
1820
exception: true)
19-
system("cockroach sql --insecure --host=localhost:26257 --execute='create database ar_crdb_console'",
21+
system("cockroach sql --insecure --host=localhost:26257 --execute='create database #{DB_NAME}'",
2022
exception: true)
2123

2224
ActiveRecord::Base.establish_connection(
23-
#Alternative version: "cockroachdb://root@localhost:26257/ar_crdb_console"
25+
#Alternative version: "cockroachdb://root@localhost:26257/#{DB_NAME}"
2426
adapter: "cockroachdb",
2527
host: "localhost",
2628
port: 26257,
2729
user: "root",
28-
database: "ar_crdb_console"
30+
database: DB_NAME
2931
)
3032

3133
load "#{__dir__}/console_schemas/#{schema_kind}.rb"

bin/console_schemas/default.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ class Post < ActiveRecord::Base
66
t.string :title
77
t.text :body
88
end
9+
10+
add_index("posts", ["title"], name: "index_posts_on_title", unique: true)
911
end

test/cases/reproduction_test.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# frozen_string_literal: true
2+
3+
require "cases/helper"
4+
5+
module CockroachDB
6+
class ReproductionTest < ActiveRecord::TestCase
7+
8+
class T < ActiveRecord::Base
9+
end
10+
11+
class U < ActiveRecord::Base
12+
end
13+
14+
class V < ActiveRecord::Base
15+
end
16+
17+
def test_the_thing
18+
T.connection.execute <<-SQL
19+
CREATE TABLE ts(a INT NOT VISIBLE, b INT, PRIMARY KEY (a,b));
20+
SQL
21+
U.connection.execute <<-SQL
22+
CREATE TABLE us(a INT PRIMARY KEY USING HASH WITH (bucket_count=4))
23+
SQL
24+
# V.connection.execute <<-SQL
25+
# create table vs(id uuid primary key default gen_random_uuid(), name string);
26+
# alter database #{DB_NAME} set primary region 'local';
27+
# Alter table vs set locality regional by row;
28+
# SQL
29+
30+
pp T.connection.indexes("ts")
31+
pp T.connection.indexes("us")
32+
33+
# migration = Class.new(ActiveRecord::Migration[7.0]) {
34+
# def migrate(x)
35+
# remove_index :us, :a
36+
# end
37+
# }.new
38+
39+
# connection_pool = ActiveRecord::Base.connection_pool
40+
# schema_migration = connection_pool.schema_migration
41+
# internal_metadata = connection_pool.internal_metadata
42+
# ActiveRecord::Migrator.new(:up, [migration], schema_migration, internal_metadata).migrate
43+
end
44+
end
45+
end

test/excludes/AttributeMethodsTest.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)