Files
ent/examples/viewschema
eiixy 21ecfa0872 entc: update groupReceiver and selectReceiver (#4395)
* update GroupReceiver and SelectReceiver

* update examples

* update entc/integration generated code

* Update entc/gen/type.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

---------

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2025-05-23 15:20:27 +07:00
..
2024-07-28 19:00:47 +03:00

Define PostgreSQL Views in Ent Schema

This example demonstrates how to define an ent.View with its SQL definition (AS ...) specified in the Ent schema.

The second approach is to define an ent.View but keep its definition and creation externally using the Atlas composite_schema data source (see examples/viewcomposite for more information).

The main advantage of this example approach is that the CREATE VIEW correctness is checked during migration and not during queries. For example, if one of the ent.Fields defined in your ent/schema does not exist in your SQL definition, PostgreSQL will return the following error:

create "clean_users" view: pq: CREATE VIEW specifies more column names than columns