<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Migrations on DPG — Declarative PG</title><link>https://thec1oud.github.io/dpg/docs/migrations/</link><description>Recent content in Migrations on DPG — Declarative PG</description><generator>Hugo</generator><language>en</language><atom:link href="https://thec1oud.github.io/dpg/docs/migrations/index.xml" rel="self" type="application/rss+xml"/><item><title>Lifecycle Directives</title><link>https://thec1oud.github.io/dpg/docs/migrations/lifecycle/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://thec1oud.github.io/dpg/docs/migrations/lifecycle/</guid><description>&lt;p>Lifecycle directives live inside &lt;code>{ }&lt;/code> blocks. They communicate intent to the compiler for operations that cannot be expressed as a simple &lt;code>CREATE&lt;/code> or &lt;code>ALTER&lt;/code>.&lt;/p>
&lt;hr>
&lt;h2 id="renamed-from--object-renames">RENAMED FROM — object renames&lt;/h2>
&lt;h3 id="schema-rename">Schema rename&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sql" data-lang="sql">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#cf222e">SCHEMA&lt;/span>&lt;span style="color:#fff"> &lt;/span>reporting&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#f6f8fa;background-color:#82071e">{&lt;/span>&lt;span style="color:#fff">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#fff"> &lt;/span>RENAMED&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#cf222e">FROM&lt;/span>&lt;span style="color:#fff"> &lt;/span>old_reporting&lt;span style="color:#1f2328">;&lt;/span>&lt;span style="color:#fff">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#fff">&lt;/span>&lt;span style="color:#f6f8fa;background-color:#82071e">}&lt;/span>&lt;span style="color:#fff">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sql" data-lang="sql">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#57606a">-- emits
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#57606a">&lt;/span>&lt;span style="color:#cf222e">ALTER&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#cf222e">SCHEMA&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#0a3069">&amp;#34;old_reporting&amp;#34;&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#cf222e">RENAME&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#cf222e">TO&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#0a3069">&amp;#34;reporting&amp;#34;&lt;/span>&lt;span style="color:#1f2328">;&lt;/span>&lt;span style="color:#fff">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="table-rename">Table rename&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sql" data-lang="sql">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#cf222e">TABLE&lt;/span>&lt;span style="color:#fff"> &lt;/span>user_accounts&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#1f2328">(&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#1f2328">...&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#1f2328">)&lt;/span>&lt;span style="color:#fff">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#fff">&lt;/span>&lt;span style="color:#f6f8fa;background-color:#82071e">{&lt;/span>&lt;span style="color:#fff">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#fff"> &lt;/span>RENAMED&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#cf222e">FROM&lt;/span>&lt;span style="color:#fff"> &lt;/span>users&lt;span style="color:#1f2328">;&lt;/span>&lt;span style="color:#fff">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#fff">&lt;/span>&lt;span style="color:#f6f8fa;background-color:#82071e">}&lt;/span>&lt;span style="color:#fff">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sql" data-lang="sql">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#57606a">-- emits
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#57606a">&lt;/span>&lt;span style="color:#cf222e">ALTER&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#cf222e">TABLE&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#0a3069">&amp;#34;public&amp;#34;&lt;/span>&lt;span style="color:#1f2328">.&lt;/span>&lt;span style="color:#0a3069">&amp;#34;users&amp;#34;&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#cf222e">RENAME&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#cf222e">TO&lt;/span>&lt;span style="color:#fff"> &lt;/span>&lt;span style="color:#0a3069">&amp;#34;user_accounts&amp;#34;&lt;/span>&lt;span style="color:#1f2328">;&lt;/span>&lt;span style="color:#fff">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="column-rename">Column rename&lt;/h3>
&lt;p>The new name goes in both the &lt;code>( )&lt;/code> list and the &lt;code>COLUMN&lt;/code> block. The old name appears only in &lt;code>RENAMED FROM&lt;/code>.&lt;/p></description></item><item><title>Linting</title><link>https://thec1oud.github.io/dpg/docs/migrations/linting/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://thec1oud.github.io/dpg/docs/migrations/linting/</guid><description>&lt;p>The linter runs automatically as part of &lt;code>dpg plan&lt;/code>, &lt;code>dpg apply&lt;/code>, and &lt;code>dpg validate&lt;/code>. It runs over the merged IR before any SQL is generated. Lint &lt;strong>errors&lt;/strong> abort the command. Lint &lt;strong>warnings&lt;/strong> are printed to stderr but do not block.&lt;/p>
&lt;h2 id="configuration">Configuration&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-toml" data-lang="toml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#57606a"># dpg.toml&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#1f2328">[&lt;/span>&lt;span style="color:#1f2328">linter&lt;/span>&lt;span style="color:#1f2328">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#1f2328">warn_on_deprecated&lt;/span> &lt;span style="color:#1f2328">=&lt;/span> &lt;span style="color:#cf222e">true&lt;/span> &lt;span style="color:#57606a"># default&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#1f2328">require_column_comments&lt;/span> &lt;span style="color:#1f2328">=&lt;/span> &lt;span style="color:#cf222e">false&lt;/span> &lt;span style="color:#57606a"># default&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#1f2328">forbid_hardcoded_passwords&lt;/span> &lt;span style="color:#1f2328">=&lt;/span> &lt;span style="color:#cf222e">true&lt;/span> &lt;span style="color:#57606a"># default&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#1f2328">max_columns_per_table&lt;/span> &lt;span style="color:#1f2328">=&lt;/span> &lt;span style="color:#0550ae">50&lt;/span> &lt;span style="color:#57606a"># default: 50 (0 = disabled)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h2 id="deprecated">&lt;code>deprecated&lt;/code>&lt;/h2>
&lt;p>&lt;strong>Severity:&lt;/strong> Warning — &lt;strong>Config:&lt;/strong> &lt;code>warn_on_deprecated&lt;/code> — &lt;strong>Default:&lt;/strong> enabled&lt;/p>
&lt;p>Warns when a table, column, view, or function is marked &lt;a href="lifecycle/">&lt;code>DEPRECATED&lt;/code>&lt;/a>.&lt;/p></description></item><item><title>Drift Detection</title><link>https://thec1oud.github.io/dpg/docs/migrations/drift-detection/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://thec1oud.github.io/dpg/docs/migrations/drift-detection/</guid><description>&lt;p>&lt;code>dpg verify&lt;/code> reads the live PostgreSQL catalog and compares it with the committed snapshot: the state DPG last applied. Only properties your source declares are compared. A property PostgreSQL reports but you never declared (an owner, a column&amp;rsquo;s storage mode, a role attribute left at its default) is never drift.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>dpg verify
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dpg verify --cluster production --database myapp
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>dpg verify --format json
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Exit codes: &lt;code>0&lt;/code> no drift (unmanaged objects, warnings and acknowledged items are allowed), &lt;code>1&lt;/code> drift found, &lt;code>2&lt;/code> error.&lt;/p></description></item></channel></rss>