We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5bd5d70 commit bc55874Copy full SHA for bc55874
test/db/postgresql/primary_key_is_not_the_first_column_test.rb
@@ -0,0 +1,37 @@
1
+require 'test_helper'
2
+require 'db/postgres'
3
+
4
+class PrimaryKeyIsNotTheFirstColumnTest < Test::Unit::TestCase
5
6
+ class CreateEmployees < ActiveRecord::Migration[4.2]
7
+ def self.up
8
+ create_table 'employees', :id => false do |t|
9
+ t.string :full_name, :null => false
10
+ t.primary_key :id, :serial
11
+ end
12
13
+ def self.down
14
+ drop_table 'employees'
15
16
17
18
+ def setup
19
+ CreateEmployees.up
20
21
22
+ def teardown
23
+ CreateEmployees.down
24
25
26
+ class Employee < ActiveRecord::Base
27
28
29
+ def test_returning_when_primary_key_is_not_the_first_column
30
+ e = Employee.new
31
+ e.full_name = 'Slartibartfast'
32
+ e.save!
33
+ e.reload
34
+ assert_equal 1, e.id
35
36
37
+end
0 commit comments