Comments (20)
@ydakuka this is not the same; your error says that there is no logidze_logger
function. Looks like you haven't initialized Logidze; you have to run rails generate logidze:install
, which creates a migration with all necessary functions. Note: that migration should run before any other Logidze-related migration.
from logidze.
I got the same error.
ydakuka@Yauheni-Work:~/virtual_box/project$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
ydakuka@Yauheni-Work:~/virtual_box/project$ rails -v
Rails 5.1.4
ydakuka@Yauheni-Work:~/virtual_box/project$ psql --version
psql (PostgreSQL) 9.5.10
ydakuka@Yauheni-Work:~/virtual_box/project$ rails db:migrate
== 20171230234326 AddLogidzeToUsers: migrating ================================
-- add_column(:users, :log_data, :jsonb)
-> 0.0008s
-- execute(" CREATE TRIGGER logidze_on_users\n BEFORE UPDATE OR INSERT ON users FOR EACH ROW\n WHEN (coalesce(current_setting('logidze.disabled'), '') <> 'on')\n EXECUTE PROCEDURE logidze_logger(null, 'updated_at');\n")
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedFunction: ERROR: function logidze_logger() does not exist
: CREATE TRIGGER logidze_on_users
BEFORE UPDATE OR INSERT ON users FOR EACH ROW
WHEN (coalesce(current_setting('logidze.disabled'), '') <> 'on')
EXECUTE PROCEDURE logidze_logger(null, 'updated_at');
from logidze.
Hey! Now I wish I hadn't deleted it. I don't have it locally either, but the fix is in another repo. Let me see if I can find it.
from logidze.
https://github.com/archonic/logidze-apartment
I'm not sure where the fix was but that's an example that can safely run rails db:reset
.
Update: I just remembered a minor important detail about apartment. It will run migrations in tenants with config.db_migrate_tenants = true
, but it only plugs into rails db:migrate
. It won't run tenant migrations if your migrate instruction is rails db:prepare
.
from logidze.
Hi!
Which PostgreSQL version do you use?
from logidze.
@SimonDKnight ping)
from logidze.
Closed as stale
from logidze.
Ignore the below - I discovered the issue was with the apartment gem (here). For anyone running into this issue in the future, apartment does not run sql execute statements in pg schemas.
I hope you don't mind me commenting on a closed issue, but I'm getting the same issue as ydakuka above, but while using the apartment gem like SimonGKnight. It appears that my initial logidze migration isn't being run across the pg schemas I have, which is causing it to throw the 'function not found' error.
Any ideas?
from logidze.
Hi @derekgstevens!
Check this section from the apartment
Readme.
It explains how to enhance schemas with raw SQL (that's exactly what we need to install Logidze).
from logidze.
@palkan Is raw SQL required when using Apartment + Logidze or do the previous instructions (steps 1-3) work as well?
Update: I had Apartment and Logidze working well together before I needed to reset my DB but I can't get back to a working state. I've tried every combination of steps on that link. In my seeds.rb, I create a tenant. rails db:reset
works, and running run migrations for xxx_logidze_install
and xxx_add_logidze_to_documents
works, but on saving the second version of a document I get PG::UndefinedFunction: ERROR: function hstore(documents) does not exist LINE 2: hstore(NEW.*) - hstore(OLD.*)
.
If I use config.use_sql = true
in the apartment config then reset, I get a duplicate table warning after it successfully completes the PG dump. Evidently we could use some guidance on how to mix apartment with logidze and some tips on how to maintain an app that can safely run rails db:reset
.
from logidze.
@archonic Looks like your schema doesn't have hstore
extension installed. Do you have a xxx_enable_hstore.rb
migration? And CREATE EXTENSION IF NOT EXISTS HSTORE
in your structure.sql
(if any)?
from logidze.
I've had the error above when I had the xxx_enable_hstore.rb migration. I removed it since I figured it wasn't required when this is in my schema.rb.
enable_extension "hstore"
enable_extension "plpgsql"
enable_extension "uuid-ossp"
I'm not using a structure.sql file.
Interestingly it seems to have not installed uuid-ossp
.
\dx
List of installed extensions
Name | Version | Schema | Description
---------+---------+------------+--------------------------------------------------
hstore | 1.4 | public | data type for storing sets of (key, value) pairs
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(2 rows)
More info:
I'm unable to create tenants while I have config.use_sql = true
for Apartment. It complains about the first table already existing. If I disable it, I can create tenants and work with documents without getting errors, but I can't call Logidze methods because log_data
is empty. I get Document#log_size delegated to log_data.size, but log_data is nil
. The trigger does exist however. I can query with SELECT * FROM pg_trigger;
and I can see logidze_on_documents
.
from logidze.
I have a minimal logidze + apartment application here which has the same issue:
https://github.com/archonic/logidze-apartment
If you create then update a document in the public schema, logidze will populate log_data
and everything is fine. If you create then update a document within a tenant, log_data
is not populated. I believe that's because the trigger isn't available within that schema, which is why apartment mentions the schema_search_path
and the shared_extensions
schema which holds extensions and triggers. Am I understanding that correctly?
from logidze.
@archonic Thanks for sharing an examples app! I made it work, here is a PR with a description: archonic/logidze-apartment#1
from logidze.
Beauty! 🙌 Thanks very much. Let me know if I can buy you a beer 😄
from logidze.
Let me know if I can buy you a beer
😺 Do you deliver to Moscow?))
from logidze.
https://twitter.com/palkan_tula/status/996002315701284865
Totally agree. Sounds like an idea for an app. How about an email money transfer to the email on your profile?
from logidze.
@archonic You can send me a postcard. That would be fair enough)
from logidze.
Hey @archonic! Hope you're doing well.
It looks like logidze-apartment
repo is no longer available (and my fork as well). And I can't remember what was the fix 🙂
Could you please remind me?
from logidze.
@archonic Thanks!
from logidze.
Related Issues (20)
- 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
- Not possible to use latest logidze and anyway_config with Ruby 3.3.0 HOT 1
- Make Sequel support independent from ActiveRecord and ActiveSupport
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.