Manage database code with Code Packages
masterFor complex database objects like views and functions that have inter-dependencies, use Code Packages instead of standard migrations. A code package is a directory containing an install.sql file.
Key Commands:
tern code install <path>: Directly installs the code package into the database (useful for development). It executes theinstall.sqlfile which should contain logic to drop and recreate the objects.tern code snapshot <path>: Creates a new migration file that, when run, installs the code package. This is the preferred way to deploy code package changes via standard migrations.
Example Structure:
code/
├── install.sql
├── a.sql
├── b.sql
└── c.sqlinstall.sql typically uses {{ template "filename.sql" . }} to include the component files.
tern code install path/to/code --config path/to/tern.conf
tern code snapshot path/to/code --migrations path/to/migrations