-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
db/migrations/20240210233828_create_materialized_view_names.cr
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,22 @@ | ||
class CreateMaterializedViewNames::V20240210233828 < Avram::Migrator::Migration::V1 | ||
def migrate | ||
execute <<-SQL | ||
CREATE MATERIALIZED VIEW IF NOT EXISTS all_the_names AS | ||
SELECT name FROM admins | ||
UNION ALL | ||
SELECT name FROM businesses | ||
UNION ALL | ||
SELECT name FROM customers | ||
UNION ALL | ||
SELECT name FROM employees | ||
UNION ALL | ||
SELECT name FROM users | ||
SQL | ||
end | ||
|
||
def rollback | ||
execute <<-SQL | ||
DROP MATERIALIZED VIEW IF EXISTS all_the_names | ||
SQL | ||
end | ||
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
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,5 @@ | ||
class Name < BaseModel | ||
view :all_the_names, materialized: true do | ||
column name : String | ||
end | ||
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
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