s|Twenty.connection|Twenty.db|g
This commit is contained in:
parent
1e3057b282
commit
27ce4251ac
3 changed files with 8 additions and 8 deletions
|
@ -47,7 +47,7 @@ module Twenty
|
|||
#
|
||||
# @return [void]
|
||||
def self.establish_connection(path:)
|
||||
@connection = Sequel.connect(
|
||||
@db = Sequel.connect(
|
||||
adapter: "sqlite",
|
||||
database: path
|
||||
)
|
||||
|
@ -55,10 +55,10 @@ module Twenty
|
|||
|
||||
##
|
||||
# @return [Sequel::Database::SQLite]
|
||||
# Returns the connection to a database
|
||||
def self.connection
|
||||
establish_connection unless @connection
|
||||
@connection
|
||||
# Returns a database object
|
||||
def self.db
|
||||
establish_connection unless @db
|
||||
@db
|
||||
end
|
||||
|
||||
require "sequel"
|
||||
|
|
|
@ -14,13 +14,13 @@ module Twenty::Migration
|
|||
# Run migrations
|
||||
# @return [void]
|
||||
def self.run!(options = {})
|
||||
Sequel::Migrator.run(Twenty.connection, migrations_path, options)
|
||||
Sequel::Migrator.run(Twenty.db, migrations_path, options)
|
||||
end
|
||||
|
||||
##
|
||||
# @return [Boolean]
|
||||
# Returns true when there are pending migrations
|
||||
def self.pending_migrations?
|
||||
! Sequel::Migrator.is_current?(Twenty.connection, migrations_path)
|
||||
! Sequel::Migrator.is_current?(Twenty.db, migrations_path)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Sequel.migration do
|
||||
column_exists = ->(table, column) do
|
||||
schema = Twenty.connection.schema(table)
|
||||
schema = Twenty.db.schema(table)
|
||||
schema.find { |(key,_)| key == column }
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue