View Source Vtc.Ecto.Postgres.PgTimecode.Migrations (vtc v0.10.9)
Migrations for adding timecode types, functions and constraints to a Postgres database.
Link to this section Summary
Full
Adds raw SQL queries to a migration for creating the database types, associated functions, casts, operators, and operator families.
Link to this section Full
@spec create_all() :: :ok
Adds raw SQL queries to a migration for creating the database types, associated functions, casts, operators, and operator families.
Safe to run multiple times when new functionality is added in updates to this library. Existing values will be skipped.
types-created
Types Created
Calling this macro creates the following type definitions:
CREATE TYPE timecode AS (
seconds rational,
rate framerate
);
schemas-created
Schemas Created
Up to two schemas are created as detailed by the Configuring Database Objects section below.
configuring-database-objects
Configuring Database Objects
To change where supporting functions are created, add the following to your Repo confiugration:
config :vtc, Vtc.Test.Support.Repo,
adapter: Ecto.Adapters.Postgres,
...
vtc: [
pg_timecode: [
functions_schema: :timecode,
functions_private_schema: :timecode_private,
functions_prefix: "timecode"
]
]
Option definitions are as follows:
functions_schema
: The schema for "public" functions that will have backwards compatibility guarantees and application code support. Default::public
.functions_private_schema:
The schema for for developer-only "private" functions that support the functions in the "timecode" schema. Will NOT have backwards compatibility guarantees NOR application code support. Default::public
.functions_prefix
: A prefix to add before all functions. Defaults to "timecode" for any function created in the "public" schema, and "" otherwise.
examples
Examples
defmodule MyMigration do
use Ecto.Migration
alias Vtc.Ecto.Postgres.PgTimecode
require PgTimecode.Migrations
def change do
PgTimecode.Migrations.create_all()
end
end
Link to this section PgTypes
@spec create_function_schemas() :: :ok
Creates schemas to act as namespaces for rational functions:
timecode
: for user-facing "public" functions that will have backwards compatibility guarantees and application code support.timecode_private
: for developer-only "private" functions that support the functions in the "timecode" schema. Will NOT have backwards compatibility guarantees NOR application code support.
These schemas can be configured in your Repo settings.
@spec create_type_timecode() :: :ok
Adds timecode
composite type.