DBML (dbml v0.3.0)
Summary
Functions
Generate Ecto migration files from parsed DBML tokens.
Generate Ecto schema files from parsed DBML tokens.
Parse a given string with a DBML schema definition
Parse a file containing a DBML schema definition.
Generate a DBML schema file from existing Ecto schema files.
Functions
Generate Ecto migration files from parsed DBML tokens.
Options
:base_timestamp- integer timestamp prefix for file names (default: 20000101000000). Each table getsbase + index.:update- iffalse(default), returns an error if any migration file already exists. Iftrue, compares schema with existing migrations and creates new ones for changed tables.
Returns {:ok, paths} on success, or {:error, message} if a file already exists (when update: false).
Generate Ecto schema files from parsed DBML tokens.
Options
:namespace- module namespace prefix (e.g."MyApp.Schema"). Defaults to the project name from the DBML tokens, or""if absent.:singularize- whether to singularize table names for module names (default:true). Set tofalseto use table names as-is (e.g.,users→Usersinstead ofusers→User).:update- iffalse(default), returns an error if any schema file already exists. Iftrue, overwrites existing files with the newly-generated content.
Returns {:ok, paths} on success, or {:error, message} if a file already exists (when update: false).
Parse a given string with a DBML schema definition
Example:
iex> DBML.parse("table a { c1 [pk] }")
{:ok, [table: %{name: "a", fields: [%{name: "c1", type: "[pk]"}]}]}
Parse a file containing a DBML schema definition.
Options
:inline- when true, inlines clauses that work as redirection for other clauses. Settings this may improve runtime performance at the cost of increased compilation time and bytecode size:debug- when true, writes generated clauses to:stderrfor debugging:export_combinator- make the underlying combinator function public so it can be used as part ofparsec/1from other modules:export_metadata- export metadata necessary to use this parser combinator to generate inputs
Generate a DBML schema file from existing Ecto schema files.
Reads all *.ex files in input_dir that contain use Ecto.Schema,
parses their structure, and writes a single .dbml file to output_path.
Options
:project_name- name for the DBML project block (optional).:database_type- database type string (default:"PostgreSQL").
Returns {:ok, output_path} or {:error, reason}.