From 27ce4251acba0a1a62ab3d0322fd53d11ad6d4bf Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Thu, 23 May 2024 22:08:54 -0300 Subject: [PATCH] s|Twenty.connection|Twenty.db|g --- server/lib/twenty/server.rb | 10 +++++----- server/lib/twenty/server/migration.rb | 4 ++-- .../twenty/server/migration/3_add_color_to_projects.rb | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/lib/twenty/server.rb b/server/lib/twenty/server.rb index 3a297f7..8ed9819 100644 --- a/server/lib/twenty/server.rb +++ b/server/lib/twenty/server.rb @@ -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" diff --git a/server/lib/twenty/server/migration.rb b/server/lib/twenty/server/migration.rb index 852ac81..fca3594 100644 --- a/server/lib/twenty/server/migration.rb +++ b/server/lib/twenty/server/migration.rb @@ -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 diff --git a/server/lib/twenty/server/migration/3_add_color_to_projects.rb b/server/lib/twenty/server/migration/3_add_color_to_projects.rb index 6a34da9..7448405 100644 --- a/server/lib/twenty/server/migration/3_add_color_to_projects.rb +++ b/server/lib/twenty/server/migration/3_add_color_to_projects.rb @@ -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