Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows you to override the root path directly on a per-instance basis #287

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nathanpalmer
Copy link

@nathanpalmer nathanpalmer commented Dec 12, 2019

This helps in situations where you are creating or updating views from within a Rails engine. By adding the root_path to the statement it will be able to correctly find the file.

The , root_path: Database::Engine.root is the part that is manually added. I didn't find any method of autodetecting the rails engine so this would have to be manually added after generating the migration.

Solves the issue I brought up in #261

create_view

create_view :product_stats, version: 2, root_path: Database::Engine.root

update_view

update_view :product_stats, version: 2, revert_to_version: 1, root_path: Database::Engine.root

replace_view

replace_view :product_stats, version: 2, revert_to_version: 1, root_path: Database::Engine.root

@@ -132,7 +132,7 @@ def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil,
# @example
# replace_view :engagement_reports, version: 3, revert_to_version: 2
#
def replace_view(name, version: nil, revert_to_version: nil, materialized: false)
def replace_view(name, version: nil, revert_to_version: nil, materialized: false, root_path: Rails.root)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UnusedMethodArgument: Unused method argument - revert_to_version.
Metrics/LineLength: Line is too long. [108/80]

@@ -88,7 +88,7 @@ def drop_view(name, revert_to_version: nil, materialized: false)
# @example
# update_view :engagement_reports, version: 3, revert_to_version: 2
#
def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, materialized: false)
def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, materialized: false, root_path: Rails.root)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/ParameterLists: Avoid parameter lists longer than 5 parameters. [6/5]
Lint/UnusedMethodArgument: Unused method argument - revert_to_version.
Metrics/LineLength: Line is too long. [128/80]

@@ -22,7 +22,7 @@ module Statements
# SELECT * FROM users WHERE users.active = 't'
# SQL
#
def create_view(name, version: nil, sql_definition: nil, materialized: false)
def create_view(name, version: nil, sql_definition: nil, materialized: false, root_path: Rails.root)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [104/80]

@derekprior derekprior changed the base branch from master to main June 18, 2020 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants