Migrator
dropView()
Signature
Section titled “Signature”dropView() — returns void
Available in: migration
Category: Migration Functions
Description
Section titled “Description”drops a view from the database Only available in a migration CFC
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | — | Name of the view to drop |
Examples
Section titled “Examples”// 1. Drop a view in the down() migration (reversing a createView in up())
component extends="wheels.migrator.Migration" hint="Add active users view" {
function up() {
createView(name="activeUsers")
.selectStatement(sql="SELECT id, firstName, lastName, email FROM users WHERE deletedAt IS NULL")
.create();
}
function down() {
dropView(name="activeUsers");
}
}
// 2. Drop multiple views in a single down() migration
component extends="wheels.migrator.Migration" hint="Add reporting views" {
function up() {
createView(name="publishedArticles")
.selectStatement(sql="SELECT id, title, authorId, publishedAt FROM articles WHERE publishedAt IS NOT NULL")
.create();
createView(name="activeAuthors")
.selectStatement(sql="SELECT id, firstName, lastName FROM users WHERE deletedAt IS NULL")
.create();
}
function down() {
dropView(name="publishedArticles");
dropView(name="activeAuthors");
}
}