Skip to content

Commit bf2480b

Browse files
author
github-actions
committed
update with project-syncing action
1 parent e5bcb1c commit bf2480b

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Xata database compatibility
2+
# Xata doesn't support CREATE EXTENSION statements but has plpgsql enabled by default
3+
# This must run before schema loading, hence the 00_ prefix for early loading
4+
5+
if ENV["DATABASE_URL"]&.include?("xata.sh")
6+
# Use ActiveSupport.on_load to ensure the adapter is loaded before patching
7+
ActiveSupport.on_load(:active_record) do
8+
module XataExtensionPrevention
9+
def enable_extension(name, **)
10+
Rails.logger&.info "Skipping extension '#{name}' - Xata has it enabled by default"
11+
return
12+
end
13+
end
14+
15+
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(XataExtensionPrevention)
16+
end
17+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Xata database compatibility
2+
# Xata doesn't support CREATE EXTENSION statements but has plpgsql enabled by default
3+
4+
# Prevent extension enabling when using Xata
5+
if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
6+
module XataExtensionPrevention
7+
def enable_extension(name, **)
8+
# Skip enabling extensions on Xata (they're already enabled)
9+
if ENV["DATABASE_URL"]&.include?("xata.sh")
10+
Rails.logger&.info "Skipping extension '#{name}' - Xata has it enabled by default"
11+
return
12+
end
13+
super
14+
end
15+
end
16+
17+
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(XataExtensionPrevention)
18+
end

0 commit comments

Comments
 (0)