Skip to content

Commit

Permalink
release 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
7even committed Mar 13, 2019
1 parent cbbb49e commit 705b3ae
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
source 'https://rubygems.org'

gem 'db_schema-definitions', github: 'db-schema/definitions', branch: 'primary_keys'
gem 'db_schema-reader-postgres', github: 'db-schema/reader-postgres', branch: 'primary_keys'

# Specify your gem's dependencies in db_schema.gemspec
gemspec
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ But you would lose it even with manual migrations.
Add these lines to your application's Gemfile:

``` ruby
gem 'db_schema', '= 0.5.rc1'
gem 'db_schema-reader-postgres', '= 0.2.rc1'
gem 'db_schema', '~> 0.5.0'
gem 'db_schema-reader-postgres', '~> 0.2.0'
```

And then execute:
Expand All @@ -72,6 +72,23 @@ $ gem install db_schema db_schema-reader-postgres
The `db_schema-reader-postgres` [gem](https://github.com/db-schema/reader-postgres) is a PostgreSQL adapter
for `DbSchema::Reader` (a module which is responsible for reading the current database schema).

## Upgrading to 0.5

Version 0.5 introduced full support for serial fields and primary keys slightly changing the DSL for
defining the primary key:

``` ruby
db.table :users do |t|
# before 0.5
t.primary_key :id
# since 0.5
t.serial :id, primary_key: true
end
```

So if you get an `Index "users_pkey" refers to a missing field "users.id"` error you should change
your schema definition to the new syntax.

## Usage

First you need to configure DbSchema so it knows how to connect to your database. This should happen
Expand Down Expand Up @@ -101,14 +118,14 @@ load application_root.join('db/schema.rb')
This `db/schema.rb` file will contain a description of your database structure
(you can choose any filename you want). When you load this file it instantly
applies the described structure to your database. Be sure to keep this file
under version control as it will be a single source of truth about
under version control as it will be the single source of truth about
the database structure.

``` ruby
# db/schema.rb
DbSchema.describe do |db|
db.table :users do |t|
t.primary_key :id
t.serial :id, primary_key: true
t.varchar :email, null: false, unique: true
t.varchar :password_digest, length: 40
t.timestamptz :created_at
Expand Down Expand Up @@ -230,8 +247,6 @@ Conditional migrations are described [here](https://github.com/db-schema/core/wi

## Known problems and limitations

* composite primary keys are not supported
* auto-incremented integer field can only be created as a primary key
* array element type attributes are not supported
* precision in all date/time types isn't supported
* no support for databases other than PostgreSQL
Expand Down
4 changes: 2 additions & 2 deletions db_schema.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency 'sequel'
spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
spec.add_runtime_dependency 'db_schema-definitions', '= 0.2.rc1'
spec.add_runtime_dependency 'db_schema-definitions', '~> 0.2.0'

spec.add_development_dependency 'bundler', '~> 1.11'
spec.add_development_dependency 'rake', '~> 10.0'
Expand All @@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'terminal-notifier'
spec.add_development_dependency 'terminal-notifier-guard'

spec.add_development_dependency 'db_schema-reader-postgres', '= 0.2.rc1'
spec.add_development_dependency 'db_schema-reader-postgres', '~> 0.2.0'
end
2 changes: 1 addition & 1 deletion lib/db_schema/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module DbSchema
VERSION = '0.5.rc1'
VERSION = '0.5'
end

0 comments on commit 705b3ae

Please sign in to comment.