Comments (8)
I jump into this issue when I dump (pg_dump) a production database and restore (pg_restore) it in development. My solution to this has been to execute, after the restore, the following task (and then restart the server, of course):
namespace :logidze do
desc 'Post restore task'
task post_restore: :environment do
logidze_variables = <<-SQL
DO $$
BEGIN
EXECUTE 'ALTER DATABASE ' || quote_ident(current_database()) || ' SET logidze.disabled=' || quote_literal('');
EXECUTE 'ALTER DATABASE ' || quote_ident(current_database()) || ' SET logidze.responsible=' || quote_literal('');
END;
$$
LANGUAGE plpgsql;
SQL
ActiveRecord::Base.connection.execute(logidze_variables)
end
end
My routine, when restoring a db, is then:
$ createdb app_name_development
$ pg_restore -O -c -j 10 -h localhost -p 5432 -d app_name_development /path/to/production/pg_dump
$ rails logidze:post_restore
So just in case someone has the same problem, this way it works for me.
from logidze.
Please, try SHOW logidze.disabled;
in psql console (or from Ruby, it doesn't matter).
If it raises the same error then you haven't set this variable. It is set by install migration for current database (https://github.com/palkan/logidze/blob/master/lib/generators/logidze/install/templates/migration.rb.erb#L6).
from logidze.
@palkan Yep, its its working same as other similar queries. And still in my rails application I am facing the same error. Is that has to anything with transactions or activerecord connection pool ?
from logidze.
I think the issue was facing was due to different reason, and its seems to be fixed for me, not related to the gem. When I upgraded to 9.5 old postgres was still running and accepting connections, so it causing mismatches.
from logidze.
Rails 5.0.0.1
Logidze 0.3.0
Postgres 9.5.4 (gem pg 0.18.4)
ActiveRecord is configured to store database structure in sql format (to be able to track stored procedures in schema dump)
module Dashboard
class Application < Rails::Application
config.active_record.schema_format = :sql
end
end
Logidze initial migration sets both logidze.disabled
and logidze.responsible
variables. But structure.sql doesn't include them(only default ones like SET client_encoding = 'UTF8'
). So rake db:reset
task is not able to set logidze variables.
Is this the same issue?
from logidze.
@sharshenov Have you checked SHOW logidze.disabled;
?
from logidze.
Sure. When migrations are forced to run:
rake db:drop db:create db:migrate
rails dbconsole
SHOW logidze.disabled;
logidze.disabled
------------------
off
(1 row)
When database schema is loaded from structure.sql:
rake db:reset
rails dbconsole
SHOW logidze.disabled;
ERROR: unrecognized configuration parameter "logidze.disabled
from logidze.
I did some investigation and found out the following: db:structure:dump
uses pg_dump
to generate structure.sql
. Unfortunately, pg_dump
doesn't include user-defined DB variables, because, from the PostgreSQL point of view, they are cluster-level.
And there is another command – pg_dump_all
– for dumping the whole cluster which includes such variables.
from logidze.
Related Issues (20)
- 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
- Not possible to use latest logidze and anyway_config with Ruby 3.3.0 HOT 1
- Make Sequel support independent from ActiveRecord and ActiveSupport
- Updating history when column names change HOT 3
- Filter by changed attrs HOT 2
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.