Skeema Premium includes the ability to manage views. When first upgrading from the Community edition CLI to the Premium edition, be sure to run skeema pull
one time to bring in any views to the filesystem.
Options
The ignore-view regex option may be used to force Skeema to ignore particular views or even all views. Additionally, since views share a namespace with tables in the database, the ignore-table option applies to both tables and views.
If you wish to restrict or ban views in your environment, see the lint-has-view option.
Several options relate to DEFINER
user clauses. These options affect views, as well as other types of stored objects. See definer management for more information.
The database stores views in a canonical format which places the entire query on a single long line, also stripping any inline SQL comments. Users will typically want to reformat views manually. For this reason, by default skeema pull
, skeema lint
, and skeema format
won’t modify or reformat existing CREATE VIEW
statements in the filesystem. The update-views option must be used to specifically update or reformat existing views. Pay special attention to that option’s documentation relating to skeema pull
, since by default this command does not update definitions of existing views, even if an ALTER VIEW
statement was run manually / outside of Skeema.
If a view name begins with “_seed_”, it is interpreted as a special seed view and it will not be diffed, pushed, or pulled as usual. With seed views, the filesystem representation is always considered canonical, rather than the database-side definition. The update-seed-inserts option controls interactions between skeema pull
updating seed data INSERT statements based on data queried from views.
Privileges
In order to manage views, Skeema’s database user needs the CREATE VIEW
and SHOW VIEW
privileges on all relevant databases. See the privileges section of the requirements documentation.
If you wish to manage views that have a different DEFINER
than Skeema’s database user, be sure to read about DEFINER
stripping in the definer management documentation.
Manipulating views
Views may be altered atomically (Skeema uses ALTER VIEW
as needed), so altering a view is not considered an unsafe action.
Dropping a view is considered a destructive action, requiring the allow-unsafe option. Although views do not “store” data and can be recreated quickly, an accidental DROP VIEW
can still be very disruptive to application queries.
If you receive unexpected errors when operating on views, check your Skeema config for connect-options and try removing any overrides to sql_mode
. These sql_mode
overrides are rarely needed in Skeema v1.5+.
Cross-schema views
Skeema only operates on a single database schema at a time, and does not resolve ordering dependencies between multiple schemas. Cross-schema views (i.e. the view’s FROM
clause references tables/views in a different database) can be problematic for this reason. See the cross-schema references documentation for more information.