Migration

/views/vadmin/Migrations.html (926 B)

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{% import (
"strings"

"{{{ .Package }}}/app"
"{{{ .Package }}}/app/controller/cutil"
"{{{ .Package }}}/app/lib/database/migrate"
"{{{ .Package }}}/views/components"
"{{{ .Package }}}/views/layout"
) %}

{% code type Migrations struct {
layout.Basic
Available migrate.MigrationFiles
Applied migrate.Migrations
} %}

{% func (p *Migrations) Body(as *app.State, ps *cutil.PageState) %}
<div class="card">
<h3>Database Migrations</h3>
</div>
{%- for idx, mf := range p.Available -%}
<div class="card">
<div class="right">
{%- code curr := p.Applied.GetByIndex(idx+1) -%}
{%- if curr == nil -%}
<em>Not Applied</em>
{%- else -%}
Applied {%= components.DisplayTimestamp(&curr.Created) %}
{%- endif -%}
</div>
<h3>{%s mf.Title %}</h3>
{%s= cutil.FormatLangIgnoreErrors(strings.TrimSpace(mf.Content), "sql") %}
</div>
{%- endfor -%}
{% endfunc %}