Comments (8)
I'd prefer to start with Sequel support within this gem.
Otherwise we have to extract core functionality into, say, logidze-core
and thus support at least 3 gems: logidze
(for ActiveRecord), logidze-core
and logidze-sequel
. And most of the features would require changes in both core and specific adapter projects.
Can you describe, please, how do you expect Logidze to work with Sequel?
from logidze.
We could start by using sequel-rails
. It provides a migration API that is almost identical to ActiveRecord's one.
For database queries and models we could probably use adapters.
For example:
Logidze::DB.transaction do
Logidze::DB.execute(...)
end
The DB abstraction would pick the right adapter to use automatically.
I think, much of the difficulty will be in testing. It's not hard to rewrite tests for Sequel, I just don't quite know how to organize them.
from logidze.
First of all, we should extract SQL generation from migrations to make it possible to use them in both AR and Sequel migrations without any modification. Smth like:
class LogdizeAR < ActiveRecord::Migration
def up
execute Logidze::SQ::Install.up(upgrade: true)
end
def down
execute Logidze::SQL::Install.down
end
end
Sequel.migration do
up { run Logidze::SQL::Install.up(upgrade: true) }
down { run Logidze::SQL::Install.down }
end
We can event do that the Rails way using custom commands:
class LogdizeInstall < ActiveRecord::Migration
def change
create_logidze
end
end
class LogdizePost < ActiveRecord::Migration
def change
add_logidze :posts, timestamp_column: :published_at, whitelist: %w(title body)
end
end
from logidze.
Actually, we don't have to extract any SQL. I was able to create a Sequel migration just by changing:
class <%= @migration_class_name %> < ActiveRecord::Migration
require 'logidze/migration'
include Logidze::Migration
def up
# stuff
end
# ...
end
To:
require 'logidze/migration'
include Logidze::Migration
Sequel.migration do
up do
# exactly the same stuff
end
# ...
end
So maybe we should extract everything but SQL generation since it's the same anyways?
from logidze.
Sorry, I don't understand what do you mean by "extract everything but SQL generation"
from logidze.
On a second thought, my idea is pretty weird. :)
You are right, we should extract SQL generation into separate erb
templates.
from logidze.
I guess we should do the same for all ActiveRecord
invocations.
We'll need a database wrapper to encapsulate ActiveRecord::Base.connection
and Sequel::Model.db
(Logidze::DB
?). Also, we'll need a model wrapper to encapsulate ActiveRecord::Base
and Sequel::Model
(Logidze::Model
if we rename the existing module to Logidze::ModelExtensions
?)
How should we detect which one to use, AR or Sequel?
from logidze.
An update on this: sequel-rails doesn't seem to be actively maintained, and, most likely, isn't used much. Looks like we'll have to go without it.
from logidze.
Related Issues (20)
- Logidze with Ruby 3.0 is throwing argument errors. HOT 2
- `rails destroy logidze:model MyModel` does not delete migration file HOT 2
- Activerecord table_name_prefix or table_name_suffix are not honored HOT 3
- Tracking changes on JSONB column error
- How to list all versions of a record? HOT 4
- Association versioning with ignore_log_data and at(version: ) doesn't return expected results HOT 5
- Partition-friendly logging (triggers) HOT 3
- JSONB column and switch_to! with append: true HOT 2
- PG::UndefinedFunction: ERROR: function hstore(model_name) does not exist HOT 1
- Meta per request HOT 1
- Logidze.ignore_log_data_by_default causing db:migrate errors HOT 2
- Responsible from different sources HOT 3
- Associations versioning - accessing versions with `at(version: #)` HOT 2
- How to tell logidze about a new column HOT 8
- GlobalID support for metadata
- `responsible_id` is not updated on relation with `touch: true` HOT 6
- reload_log_data doesn't work when used with acts_as_paranoid and deleted records HOT 2
- docs: logdize cannot set session meta data when using a connection pool HOT 1
- How can I get the last 100 versions of a model? regardless of the record HOT 2
- Saving log with only metadata changes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logidze.