Skip to content

Commit

Permalink
Merge pull request #9 from nbulaj/sequel_fix
Browse files Browse the repository at this point in the history
Fix Sequel database error for non-existing tables
  • Loading branch information
nbulaj authored Dec 15, 2017
2 parents 3772941 + 7c8b137 commit d12d4f7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ https://github.com/nbulaj/doorkeeper-sequel/compare/1.3.0...master

...

## `1.3.1` (2017-12-14)

https://github.com/nbulaj/doorkeeper-sequel/compare/1.3.0...1.3.1

* Fix Sequel model initialization (database error for rake tasks)
* Fix main migration name for generator

## `1.3.0` (2017-12-13)

https://github.com/nbulaj/doorkeeper-sequel/compare/1.2.3...1.3.0
Expand Down
2 changes: 1 addition & 1 deletion doorkeeper-sequel.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
gem.name = 'doorkeeper-sequel'
gem.version = DoorkeeperSequel.gem_version
gem.authors = ['Nikita Bulai']
gem.date = '2017-12-13'
gem.date = '2017-12-14'
gem.email = ['bulajnikita@gmail.com']
gem.homepage = 'http://github.com/nbulaj/doorkeeper-sequel'
gem.summary = 'Doorkeeper Sequel ORM'
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper-sequel/gem_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def self.gem_version
module VERSION
MAJOR = 1
MINOR = 3
TINY = 0
TINY = 1

STRING = [MAJOR, MINOR, TINY].compact.join('.')
end
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper-sequel/generators/migration_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MigrationGenerator < ::Thor::Group
desc 'Installs Doorkeeper Sequel migration file.'

def install
create_migration 'migration.rb'
create_migration 'create_doorkeeper_tables.rb'
end
end
end
18 changes: 14 additions & 4 deletions lib/doorkeeper/orm/sequel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ module Doorkeeper
module Orm
module Sequel
def self.initialize_models!
require 'doorkeeper/orm/sequel/models/concerns/sequel_compat'
require 'doorkeeper/orm/sequel/access_grant'
require 'doorkeeper/orm/sequel/access_token'
require 'doorkeeper/orm/sequel/application'
# Hack to bypass Sequel restrictions to model datasets definition.
# As it requires valid existing table at the moment of Model class definition,
# all the rake tasks (db:create, db:migrate, etc) would be aborted due to error.
old_value = ::Sequel::Model.require_valid_table
::Sequel::Model.require_valid_table = false

begin
require 'doorkeeper/orm/sequel/models/concerns/sequel_compat'
require 'doorkeeper/orm/sequel/access_grant'
require 'doorkeeper/orm/sequel/access_token'
require 'doorkeeper/orm/sequel/application'
ensure
::Sequel::Model.require_valid_table = old_value
end
end

def self.initialize_application_owner!
Expand Down

0 comments on commit d12d4f7

Please sign in to comment.