s|Twenty.connection|Twenty.db|g

This commit is contained in:
0x1eef 2024-05-23 22:08:54 -03:00
parent 1e3057b282
commit 27ce4251ac
3 changed files with 8 additions and 8 deletions

View file

@ -47,7 +47,7 @@ module Twenty
# #
# @return [void] # @return [void]
def self.establish_connection(path:) def self.establish_connection(path:)
@connection = Sequel.connect( @db = Sequel.connect(
adapter: "sqlite", adapter: "sqlite",
database: path database: path
) )
@ -55,10 +55,10 @@ module Twenty
## ##
# @return [Sequel::Database::SQLite] # @return [Sequel::Database::SQLite]
# Returns the connection to a database # Returns a database object
def self.connection def self.db
establish_connection unless @connection establish_connection unless @db
@connection @db
end end
require "sequel" require "sequel"

View file

@ -14,13 +14,13 @@ module Twenty::Migration
# Run migrations # Run migrations
# @return [void] # @return [void]
def self.run!(options = {}) def self.run!(options = {})
Sequel::Migrator.run(Twenty.connection, migrations_path, options) Sequel::Migrator.run(Twenty.db, migrations_path, options)
end end
## ##
# @return [Boolean] # @return [Boolean]
# Returns true when there are pending migrations # Returns true when there are pending migrations
def self.pending_migrations? def self.pending_migrations?
! Sequel::Migrator.is_current?(Twenty.connection, migrations_path) ! Sequel::Migrator.is_current?(Twenty.db, migrations_path)
end end
end end

View file

@ -2,7 +2,7 @@
Sequel.migration do Sequel.migration do
column_exists = ->(table, column) do column_exists = ->(table, column) do
schema = Twenty.connection.schema(table) schema = Twenty.db.schema(table)
schema.find { |(key,_)| key == column } schema.find { |(key,_)| key == column }
end end