File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments