@@ -53,8 +53,8 @@ But you would lose it even with manual migrations.
5353Add these lines to your application's Gemfile:
5454
5555``` ruby
56- gem ' db_schema' , ' = 0.5.rc1 '
57- gem ' db_schema-reader-postgres' , ' = 0.2.rc1 '
56+ gem ' db_schema' , ' ~> 0.5.0 '
57+ gem ' db_schema-reader-postgres' , ' ~> 0.2.0 '
5858```
5959
6060And then execute:
@@ -72,6 +72,23 @@ $ gem install db_schema db_schema-reader-postgres
7272The ` db_schema-reader-postgres ` [ gem] ( https://github.com/db-schema/reader-postgres ) is a PostgreSQL adapter
7373for ` DbSchema::Reader ` (a module which is responsible for reading the current database schema).
7474
75+ ## Upgrading to 0.5
76+
77+ Version 0.5 introduced full support for serial fields and primary keys slightly changing the DSL for
78+ defining the primary key:
79+
80+ ``` ruby
81+ db.table :users do |t |
82+ # before 0.5
83+ t.primary_key :id
84+ # since 0.5
85+ t.serial :id , primary_key: true
86+ end
87+ ```
88+
89+ So if you get an ` Index "users_pkey" refers to a missing field "users.id" ` error you should change
90+ your schema definition to the new syntax.
91+
7592## Usage
7693
7794First you need to configure DbSchema so it knows how to connect to your database. This should happen
@@ -101,14 +118,14 @@ load application_root.join('db/schema.rb')
101118This ` db/schema.rb ` file will contain a description of your database structure
102119(you can choose any filename you want). When you load this file it instantly
103120applies the described structure to your database. Be sure to keep this file
104- under version control as it will be a single source of truth about
121+ under version control as it will be the single source of truth about
105122the database structure.
106123
107124``` ruby
108125# db/schema.rb
109126DbSchema .describe do |db |
110127 db.table :users do |t |
111- t.primary_key :id
128+ t.serial :id , primary_key: true
112129 t.varchar :email , null: false , unique: true
113130 t.varchar :password_digest , length: 40
114131 t.timestamptz :created_at
@@ -230,8 +247,6 @@ Conditional migrations are described [here](https://github.com/db-schema/core/wi
230247
231248## Known problems and limitations
232249
233- * composite primary keys are not supported
234- * auto-incremented integer field can only be created as a primary key
235250* array element type attributes are not supported
236251* precision in all date/time types isn't supported
237252* no support for databases other than PostgreSQL
0 commit comments