btihen commented on issue #370:
URL: https://github.com/apache/age/issues/370#issuecomment-2118767628
Solution to tests - rails generates a flawed `schema.rb` - replace the AGE
part with:
```ruby
# db/schema.rb
ActiveRecord::Schema[7.1].define(version: 2024_05_05_183043) do
execute('CREATE EXTENSION IF NOT EXISTS age;')
execute <<-SQL
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM pg_namespace
WHERE nspname = 'ag_catalog'
) THEN
CREATE SCHEMA ag_catalog;
END IF;
END $$;
SQL
# These are extensions that must be enabled in order to support this
database
enable_extension 'age'
enable_extension 'plpgsql'
# Load the age code
execute("LOAD 'age';")
# Load the ag_catalog into the search path
execute('SET search_path = ag_catalog, "$user", public;')
execute <<-SQL
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM pg_constraint
WHERE conname = 'fk_graph_oid'
) THEN
ALTER TABLE ag_label ADD CONSTRAINT fk_graph_oid FOREIGN KEY (graph)
REFERENCES ag_graph (graphid);
END IF;
END $$;
SQL
# create_schema 'age_schema'
execute <<-SQL
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM ag_catalog.ag_graph
WHERE name = 'age_schema'
) THEN
PERFORM create_graph('age_schema');
END IF;
END $$;
SQL
end
```
be sure to commit this and restore it with each subsequent migration (just
keeping the new stuff) - as rails (for now) will repeatedly reset the schema to
wht it thinks is correct, but is actually incorrect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]