-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent Rails 7.1 create_schema from being added to db/schema.rb (#276)
* Prevent Rails 7.1 create_schema from being added to db/schema.rb as schemas are managed by Apartment not ActiveRecord like they would be in a vanilla Rails setup. * Need to also require the abstract superclass * Only suppress create_schema when use_schemas = true
- Loading branch information
1 parent
44ee01b
commit 0c0faf1
Showing
2 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This patch prevents `create_schema` from being added to db/schema.rb as schemas are managed by Apartment | ||
# not ActiveRecord like they would be in a vanilla Rails setup. | ||
|
||
require "active_record/connection_adapters/abstract/schema_dumper" | ||
require "active_record/connection_adapters/postgresql/schema_dumper" | ||
|
||
class ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper | ||
alias_method :_original_schemas, :schemas | ||
def schemas(stream) | ||
_original_schemas(stream) unless Apartment.use_schemas | ||
end | ||
end |