Skip to content

Commit 6dde848

Browse files
BuonOmorafiss
authored andcommitted
docs: add issue template
1 parent 11c2767 commit 6dde848

File tree

3 files changed

+155
-0
lines changed

3 files changed

+155
-0
lines changed

.github/issue_template.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!-- NOTE: This template is copying most of the Rails repo template -->
2+
3+
### Steps to reproduce
4+
5+
<!-- (Guidelines for creating a bug report are [available
6+
here](https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#creating-a-bug-report)) -->
7+
8+
<!-- Paste your executable test case created from one of the scripts found [here](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/tree/master/.github/reproduction_scripts) below: -->
9+
10+
```ruby
11+
# Your reproduction script goes here
12+
```
13+
14+
### Expected behavior
15+
16+
<!-- Tell us what should happen -->
17+
18+
### Actual behavior
19+
20+
<!-- Tell us what happens instead -->
21+
22+
### System configuration
23+
24+
<!-- Either fill manually or paste the output of this script within code blocks:
25+
26+
```bash
27+
bundle info rails | head -1 &&
28+
ruby -v &&
29+
bundle info activerecord-cockroachdb-adapter | head -1 &&
30+
cockroach --version
31+
```
32+
-->
33+
34+
<!--
35+
```
36+
# output here (and uncomment!)
37+
```
38+
-->
39+
40+
**Rails version**:
41+
42+
**Ruby version**:
43+
44+
**Adapter version**:
45+
46+
**CockroachDB version**:
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# frozen_string_literal: true
2+
#
3+
# Adapted from https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_record_migrations.rb
4+
5+
require "bundler/inline"
6+
7+
gemfile(true) do
8+
source "https://rubygems.org"
9+
10+
gem "activerecord"
11+
12+
gem "activerecord-cockroachdb-adapter"
13+
end
14+
15+
require "activerecord-cockroachdb-adapter"
16+
require "minitest/autorun"
17+
require "logger"
18+
19+
# You might want to change the database name for another one.
20+
ActiveRecord::Base.establish_connection("cockroachdb://root@localhost:26257/defaultdb")
21+
ActiveRecord::Base.logger = Logger.new(STDOUT)
22+
23+
ActiveRecord::Schema.define do
24+
create_table :payments, force: true do |t|
25+
t.decimal :amount, precision: 10, scale: 0, default: 0, null: false
26+
end
27+
end
28+
29+
class Payment < ActiveRecord::Base
30+
end
31+
32+
class ChangeAmountToAddScale < ActiveRecord::Migration::Current # or use a specific version via `Migration[number]`
33+
def change
34+
reversible do |dir|
35+
dir.up do
36+
change_column :payments, :amount, :decimal, precision: 10, scale: 2
37+
end
38+
39+
dir.down do
40+
change_column :payments, :amount, :decimal, precision: 10, scale: 0
41+
end
42+
end
43+
end
44+
end
45+
46+
class BugTest < ActiveSupport::TestCase
47+
def test_migration_up
48+
ChangeAmountToAddScale.migrate(:up)
49+
Payment.reset_column_information
50+
51+
assert_equal "decimal(10,2)", Payment.columns.last.sql_type
52+
end
53+
54+
def test_migration_down
55+
ChangeAmountToAddScale.migrate(:down)
56+
Payment.reset_column_information
57+
58+
assert_equal "decimal(10)", Payment.columns.last.sql_type
59+
end
60+
end
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# frozen_string_literal: true
2+
#
3+
# Adapted from https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_record.rb
4+
5+
require "bundler/inline"
6+
7+
gemfile(true) do
8+
source "https://rubygems.org"
9+
10+
gem "activerecord"
11+
12+
gem "activerecord-cockroachdb-adapter"
13+
end
14+
15+
require "activerecord-cockroachdb-adapter"
16+
require "minitest/autorun"
17+
require "logger"
18+
19+
# You might want to change the database name for another one.
20+
ActiveRecord::Base.establish_connection("cockroachdb://root@localhost:26257/defaultdb")
21+
ActiveRecord::Base.logger = Logger.new(STDOUT)
22+
23+
ActiveRecord::Schema.define do
24+
create_table :posts, force: true do |t|
25+
end
26+
27+
create_table :comments, force: true do |t|
28+
t.integer :post_id
29+
end
30+
end
31+
32+
class Post < ActiveRecord::Base
33+
has_many :comments
34+
end
35+
36+
class Comment < ActiveRecord::Base
37+
belongs_to :post
38+
end
39+
40+
class BugTest < ActiveSupport::TestCase
41+
def test_association_stuff
42+
post = Post.create!
43+
post.comments << Comment.create!
44+
45+
assert_equal 1, post.comments.count
46+
assert_equal 1, Comment.count
47+
assert_equal post.id, Comment.first.post.id
48+
end
49+
end

0 commit comments

Comments
 (0)