File: index-expr.txt

package info (click to toggle)
golang-ariga-atlas 0.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,676 kB
  • sloc: javascript: 592; sql: 404; makefile: 10
file content (64 lines) | stat: -rw-r--r-- 1,479 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
apply 1.hcl
cmpshow users 1.sql

apply 2.hcl
cmpshow users 2.sql

-- 1.hcl --
schema "$db" {}

table "users" {
  schema = schema.$db
  column "first_name" {
    null = false
    type = varchar(128)
  }
  column "last_name" {
    null = false
    type = varchar(128)
  }
  index "full_name" {
    on {
        expr = "first_name || ' ' || last_name"
    }
  }
}

-- 1.sql --
                   Table "script_index_expr.users"
   Column   |          Type          | Collation | Nullable | Default
------------+------------------------+-----------+----------+---------
 first_name | character varying(128) |           | not null |
 last_name  | character varying(128) |           | not null |
Indexes:
    "full_name" btree (((first_name::text || ' '::text) || last_name::text))


-- 2.hcl --
schema "$db" {}

table "users" {
  schema = schema.$db
  column "first_name" {
    null = false
    type = varchar(128)
  }
  column "last_name" {
    null = false
    type = varchar(128)
  }
  index "full_name" {
    on {
        expr = "first_name || '''s first name'"
    }
  }
}

-- 2.sql --
                   Table "script_index_expr.users"
   Column   |          Type          | Collation | Nullable | Default
------------+------------------------+-----------+----------+---------
 first_name | character varying(128) |           | not null |
 last_name  | character varying(128) |           | not null |
Indexes:
    "full_name" btree ((first_name::text || '''s first name'::text))