-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a rake task that installs the gem (#121)
- Loading branch information
1 parent
e478faf
commit d6e5481
Showing
6 changed files
with
109 additions
and
16 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
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,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActualDbSchema | ||
# Manages the configuration settings for the gem. | ||
class Configuration | ||
attr_accessor :enabled, :auto_rollback_disabled, :ui_enabled, :git_hooks_enabled, :multi_tenant_schemas | ||
|
||
def initialize | ||
@enabled = Rails.env.development? | ||
@auto_rollback_disabled = ENV["ACTUAL_DB_SCHEMA_AUTO_ROLLBACK_DISABLED"].present? | ||
@ui_enabled = Rails.env.development? || ENV["ACTUAL_DB_SCHEMA_UI_ENABLED"].present? | ||
@git_hooks_enabled = ENV["ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED"].present? | ||
@multi_tenant_schemas = nil | ||
end | ||
|
||
def [](key) | ||
public_send(key) | ||
end | ||
|
||
def []=(key, value) | ||
public_send("#{key}=", value) | ||
end | ||
|
||
def fetch(key, default = nil) | ||
if respond_to?(key) | ||
public_send(key) | ||
else | ||
default | ||
end | ||
end | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
lib/generators/actual_db_schema/templates/actual_db_schema.rb
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,23 @@ | ||
# frozen_string_literal: true | ||
|
||
# ActualDbSchema initializer | ||
# Adjust the configuration as needed. | ||
|
||
ActualDbSchema.configure do |config| | ||
# Enable the gem. | ||
config.enabled = Rails.env.development? | ||
|
||
# Disable automatic rollback of phantom migrations. | ||
# config.auto_rollback_disabled = true | ||
config.auto_rollback_disabled = ENV["ACTUAL_DB_SCHEMA_AUTO_ROLLBACK_DISABLED"].present? | ||
|
||
# Enable the UI for managing migrations. | ||
config.ui_enabled = Rails.env.development? || ENV["ACTUAL_DB_SCHEMA_UI_ENABLED"].present? | ||
|
||
# Enable automatic phantom migration rollback on branch switch, | ||
# config.git_hooks_enabled = true | ||
config.git_hooks_enabled = ENV["ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED"].present? | ||
|
||
# If your application leverages multiple schemas for multi-tenancy, define the active schemas. | ||
# config.multi_tenant_schemas = -> { ["public", "tenant1", "tenant2"] } | ||
end |
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