Skip to content

Commit

Permalink
chore: add postgres-diesel example
Browse files Browse the repository at this point in the history
  • Loading branch information
nlopes committed Aug 30, 2023
1 parent 81a56a1 commit 2f08ee1
Show file tree
Hide file tree
Showing 16 changed files with 310 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/postgres-diesel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "postgres-diesel"
version = "0.1.0"
edition = "2021"
authors = ["Norberto Lopes <[email protected]>"]

[dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros"], default-features = false }
database-schema = { path = "../../", features = ["diesel", "postgres"] }

8 changes: 8 additions & 0 deletions examples/postgres-diesel/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG VERSION
FROM postgres:${VERSION}-alpine

COPY ./certs /var/lib/postgresql/certs

# Fix permissions so that server starts
RUN chown 70:70 /var/lib/postgresql/certs/server-cert.pem /var/lib/postgresql/certs/server-key.pem
RUN chmod 0600 /var/lib/postgresql/certs/server-cert.pem /var/lib/postgresql/certs/server-key.pem
28 changes: 28 additions & 0 deletions examples/postgres-diesel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# postgres-diesel

This simple example will use `diesel` to run the migrations found in
[`./migrations`](./migrations) and then generate a [`./structure.sql`](./structure.sql)
file with the database schema;

# Running

```shell
# this is an example in my MacOS laptop, using postgres from homebrew, adjust as you see fit!
$ docker compose up
$ cargo run
```

## Dependencies

- `pg_dump`
- `docker compose` - if you want to run the example against a docker instance running
`postgres` server.

You might also need to help us find the postgres libraries and clients
If they are not in your default paths you will have to set them like so:

```shell
export PATH=/path/to/your/postgres-client/install-folder/bin:$PATH
export RUSTFLAGS="-L/path/to/your/lib-postgres-folder/lib"
```

19 changes: 19 additions & 0 deletions examples/postgres-diesel/certs/client-cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDBzCCAe8CAQEwDQYJKoZIhvcN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s/client-key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEArRH0RiYpclcEQu6wLO1cy5D6F4OoDh3mc/Xm5VMfJXNersLv
0rEtjzmfEFDnV37qTI+/byvVkh8ufQ1gQj3x1EkKJyc5D+xHoWZYSeSGRt7x+o7Z
PUULwqWWLnRnr2xcjDzU+WarDpxfbtA50DzXI7bNY4M6UI9rRWFyWLX/WD/Bn3rn
YE3FOGOvmv7mLFpYnUDDzrqzk6XbUFumkuazrBNs6L3Fj26FmGoYFp/25de5V9zK
aye7LgyK/M7n/icosNY8sDYuWXQaHgXh4fX12bRsp1/F9lonC+pHzzkxUcOf9/Uy
xoUay14yvA5Vahd/0elQLOIMZDq/I8wi1KIbKwIDAQABAoIBAH9tMbqYjHmoQfX6
AfMCTQmA0/KOOCU0tKH6kqeUXOFZIYRw+NzbIR1MIqaDuuF8C4yVZjC3SIdOuA7Q
02fSbgSMRpJvWZ80q8TVMvos7QSvT+DYXnCzLqaA/qNzh4fss/N5MqHyis22KrnP
TFHbCdg81tqHG1+HSUcLKYLRdZEGIQxUIN7Pr7DMKR2ykNN/xulqaN1aJ7D5kScj
rPJVd225UQNXWWh8RYVA9iN25oYOBBOrsJFxnULP3KRkDSdruok9F9GRourL1ELp
Gemxo1CIV+iM+RmsHpYxsh1qgkqVxowaz4KJMQ9PT6oOyljLDuA1g/dJc+rXSjBf
bHpacuECgYEA5pjtVTlSj+o0JV9ABC3XOBv4rYVDB0UcAJvutrqPzj5Oj+m+83sm
N+jAD2zThjwbIQtCEnmeI55iLcZWYlHhGdxJyM74fafVZe7lsKxRWoaecNPaJfT6
JJHOji9NA3WA4KO4jErEmEB/HOf4bUK91caiUFLKiltGUYSF41j26dsCgYEAwCKz
zj8bbi0pGuKRwgH9RTODhuUMHflA2LC3zknfRaFKcXlV1ddz6IPrOr0HxSVew3G0
wC6Z7yPVTE2gAy9T2MjeQX8dofFOk5g2bDN3Ac1a8MfyP78i5qt9OxiqBy2uj/lV
M0fgrw/95iRPmxyBAVvAnmjEVEu7fabHO6CUHPECgYBDw68C+2xqxF18mgga8kmr
wHSMsXuoGEQJXcmBw0NdTWwS2JL3xDnP9kLyhX2HlgQ26rMI8NprBzE82GssS3mF
+vln3IKjkn2gjdrL12e03ZiT+X3C58HWm06C9B2CpbYwzYv/Fj29rD5uhTC5EwLs
Xon2Zs4EaJw6emJKFCvDPwKBgQCGkwfbqun8lpcW5KDxAVGzOayjPCTrjZy06bok
PCutapZounK7j+f4cQW+o44gsNcaD7dpcHqTPEb25dvwvyJ8Ud0ShQVtW0YNLOzZ
hoaRdZN/2Jw9uBOq+2yAivr0gjOlVh8uBudB1vKgUsiLPUDCgdB9Y6Y34L+W98zO
X9++EQKBgHtQWPYXwoe0I7UAumPfktbBMQDUtleCEdwGISn3z1zPHSM/9uJL9hvk
mGFaJhGt9Ts1dASxdjkaZ3FEwO1yn+/ToxzODkY6u7LIpkFE0lR7rPfmWN579Q1R
rm4+saCQDNWH8vJS7ToRAz0oheO/k2x9Om3Z1L1fTsYY4U5AIHVJ
-----END RSA PRIVATE KEY-----
16 changes: 16 additions & 0 deletions examples/postgres-diesel/certs/client-req.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-----BEGIN CERTIFICATE REQUEST-----
MIICkjCCAXoCAQAwTTELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0G
A1UEBwwGTG9uZG9uMRwwGgYDVQQDDBNteXNxbC1kaWVzZWwtY2xpZW50MIIBIjAN
BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArRH0RiYpclcEQu6wLO1cy5D6F4Oo
Dh3mc/Xm5VMfJXNersLv0rEtjzmfEFDnV37qTI+/byvVkh8ufQ1gQj3x1EkKJyc5
D+xHoWZYSeSGRt7x+o7ZPUULwqWWLnRnr2xcjDzU+WarDpxfbtA50DzXI7bNY4M6
UI9rRWFyWLX/WD/Bn3rnYE3FOGOvmv7mLFpYnUDDzrqzk6XbUFumkuazrBNs6L3F
j26FmGoYFp/25de5V9zKaye7LgyK/M7n/icosNY8sDYuWXQaHgXh4fX12bRsp1/F
9lonC+pHzzkxUcOf9/UyxoUay14yvA5Vahd/0elQLOIMZDq/I8wi1KIbKwIDAQAB
oAAwDQYJKoZIhvcNAQELBQADggEBAJ/kwUYFLLqqkjnNddSwODoQkh8dyNE+gfkW
6pRYF1p/ACtQbIPddJS/xG7rb+DCEHPqQY09N0mgyBu0LiQyG14hqFsZf0fjEBv0
Of9ZaZsxQovGAGOgQ/GtO9knePpv3ZzzkNFuqKG/5X+RFke9lxqfTY4m6W9vOkeL
dfx+SBz4ZBcJ2FgOwZWLOzmpTXRWrHocsLWsO58Yb2V4tUE5S0ojQrhQbZDEFKZK
hbbwjgAvXR7YJGdOoQq6SkEqGx/gLTTEwkceSn2nRXiuJYLMdXKmoUvY8DQRNH/L
qlGC68jyQdxie1DpRToomx3URg5ceUKJeAdvNC3zb76Wg99Hsqk=
-----END CERTIFICATE REQUEST-----
27 changes: 27 additions & 0 deletions examples/postgres-diesel/certs/root-ca-key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAuBdM/TyViYfnYB2DADqg1+6AbxO8a1ZcP3NPxVgBtprhOTPT
H8Yvg0/RKQrnp6/8eNa01wobcKmfDRbpF3WrHPjOq/3FVxNbcCnezrvPxjWmFSEI
kedlokFVPSlSM8wwhHoWOGNU0OS+fiT1ixPQBEPb33xIRIg1gfGqMMlZq4I0qIWk
oVh+qQcaL9clH4RgcRVT6XPCu1fWDZRAO8MdbJr5iqfvanhAHanNIaR2Q3Ja5JsO
zB8j+CFRpf1NwSN8erOAji4ZEDRO1i6+zuveWgOpBn3tay53L8jm0zYMB2noJPqF
Ac/tH2CD/HVcGMcyLBAqIzbHK/ZTWyfBP0TloQIDAQABAoIBAD29stiL5StHJVab
D0CYaTGCkBiw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Bsz5b5PJ0WeWrn1YtxlIH2S
CShwtUK4I4/3PpqTApaJBFdE51edtJKAIwpI40g7zjy/Pc9FQPjMuz4K5BNGFtE3
WwOiQYO8iHbNJ3ZzrKTYQmD9sHLkFnqhePmfY9ttLMdgB5Xpox8C
-----END RSA PRIVATE KEY-----
19 changes: 19 additions & 0 deletions examples/postgres-diesel/certs/root-ca.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDCDCCAfACCQCgRRoacvClxzANBgkqhkiG9w0BAQsFADBGMQswCQYDVQQGEwJH
QjEPMA0GA1UECAwGTG9uZG9uMQ8wDQYDVQQHDAZMb25kb24xFTATBgNVBAMMDG15
c3FsLWRpZXNlbDAeFw0yMzA4MjgxOTM0MzBaFw0zMzA3MDYxOTM0MzBaMEYxCzAJ
BgNVBAYTAkdCMQ8wDQYDVQQIDAZMb25kb24xDzANBgNVBAcMBkxvbmRvbjEVMBMG
A1UEAwwMbXlzcWwtZGllc2VsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
AQEAuBdM/TyViYfnYB2DADqg1+6AbxO8a1ZcP3NPxVgBtprhOTPTH8Yvg0/RKQrn
p6/8eNa01wobcKmfDRbpF3WrHPjOq/3FVxNbcCnezrvPxjWmFSEIkedlokFVPSlS
M8wwhHoWOGNU0OS+fiT1ixPQBEPb33xIRIg1gfGqMMlZq4I0qIWkoVh+qQcaL9cl
H4RgcRVT6XPCu1fWDZRAO8MdbJr5iqfvanhAHanNIaR2Q3Ja5JsOzB8j+CFRpf1N
wSN8erOAji4ZEDRO1i6+zuveWgOpBn3tay53L8jm0zYMB2noJPqFAc/tH2CD/HVc
GMcyLBAqIzbHK/ZTWyfBP0TloQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQCZQyvu
ztrnkmP+/gTbdHlZMcQjA9U0aRQqesJm/O75ICGTpjxlWXXzKe/WSqP2ZoGLRbY0
Wi1KnL/V0qc8QpgCcBsNSa0VwtcTUZVTUGecGxk5BEc8dH8hfnkGy+bH2e81LmX5
cMibbkU6wH5NwgTQIkUlRlDbCiLoszAhgAOFkOFLUEIxHIea6YeRw1479nUxNXDM
ZXDsj+EGNE94HQwSiNkxfuWwpCyAOrLeBmaUaG7SvMioh5lffSJcZQ8nPWA/ZJ8n
49kAh3iwKNMGpvKOohu4e1qpFOxPgHiJ+5XKQM+YHmN1TRVzLXEsF/IgwSvb5UxQ
qXdoeBiEhSrHSkom
-----END CERTIFICATE-----
19 changes: 19 additions & 0 deletions examples/postgres-diesel/certs/server-cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDBzCCAe8CAQEwDQYJKoZIhvcNAQELBQAwRjELMAkGA1UEBhMCR0IxDzANBgNV
BAgMBkxvbmRvbjEPMA0GA1UEBwwGTG9uZG9uMRUwEwYDVQQDDAxteXNxbC1kaWVz
ZWwwHhcNMjMwODI4MTkzNjM1WhcNMzMwNzA2MTkzNjM1WjBNMQswCQYDVQQGEwJH
QjEPMA0GA1UECAwGTG9uZG9uMQ8wDQYDVQQHDAZMb25kb24xHDAaBgNVBAMME215
c3FsLWRpZXNlbC1zZXJ2ZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
AQDgRFH/Q1eoZoYRGWtDZ7DAZ0xHWtLk4qB12WA+JwwYfEG9g68JSTsyCAwFINB4
81S7sNH5+FDFmZFAKQnmIfH11LKN5jSsrZLITFlKX4tj4Hisxt5TTyBHSMBQPwoK
RtGV7dhANq5epJVRUvA5ehOEvn1Ke0x38sDihde7Z5P7PyoL1fjHALrTafu/4WsG
EfAAQFtCP5wtJRwyaI0conXBgPdBYs4acKAUMthkSfYc9VNm6JvpZZrjX0MkRLIj
3Z5PYuWVi6cI53RteIXGF6D+TS0cqQFi0cl4Gf78Au8BKjsxb/udJtzC20Jip0VJ
SdTiVta/VMZ+UQFTZD3CYJNVAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAJjHuZej
IyRLMdggq6BkV0F6rVqH2wB2dEklwZJPWmJ/v3DLwBbALsUpzVh1gh4Oa93V8Bdj
2kJWmHdFMsb/gwKzl4kHsWMskEzjDYf1RTE+qii7XPm8w8hmxbsHG+7QxJVU4iLA
9ydrsW6aBEl0O4BNcwwlMMpqGyTOFCSCWCEVe0YVIFTJ/2VJHv47wIod4kDvkegT
2+mFyY29uA3N0/zIV29wWZc2nxt+JRf/J4mO85jOm18hstBa8b7Fn4nB+ttH4Blx
7fotbaia8Kb+EgZuwmKiJAJPLdMAQt0YjHkz6JMgM7Lg3YYkwPo9iajKicPh67Tu
nINADc3fblSgyxs=
-----END CERTIFICATE-----
27 changes: 27 additions & 0 deletions examples/postgres-diesel/certs/server-key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA4ERR/0NXqGaGERlrQ2ewwGdMR1rS5OKgddlgPicMGHxBvYOv
CUk7MggMBSDQePNUu7DR+fhQxZmRQCkJ5iHx9dSyjeY0rK2SyExZSl+LY+B4rMbe
U08gR0jAUD8KCkbRle3YQDauXqSVUVLwOXoThL59SntMd/LA4oXXu2eT+z8qC9X4
xwC602n7v+FrBhHwAEBbQj+cLSUcMmiNHKJ1wYD3QWLOGnCgFDLYZEn2HPVTZuib
6WWa419DJESyI92eT2LllYunCOd0bXiFxheg/k0tHKkBYtHJeBn+/ALvASo7MW/7
nSbcwttCYqdFSUnU4lbWv1TGflEBU2Q9wmCTVQIDAQABAoIBAQDWFiI4ja7GYWim
Nh/BLuD6KyIUE82zFeyb07EeY+QWE7gmE+kp8jCCKFBhLNwWOiOvMLKh77wbhee0
2fhLKihyxmLVNucd2GyArPGoH+FOrOBF/2oJGUX1Bqwfbq5E9Snp+C0xz4FRc8fe
5E/SbojndXjheyaacrBTDfXNPqlzcyUErpKeNeTA7IEYumxXrL/QfZ3BramSjtDS
168DVWmDZStFjjaoMHjen5VOJiTBZCScA00fx15pCVRfA1hxzLK/yiPldSyUwP0T
CdxTKtK8NxHZCBcIKQa/rje2E/nYyOAF0UseKQdVL32mw5mVNg7Sdanu/4ef3qAh
jhVEbK2ZAoGBAPiw84BLZFHEjOcFWXjnP6svJOqUJDHtTX3CBeMJqATpLqc32G/h
ncV439NKuDXdeG8XuHz2CeRdHmzr1wGqwiUOMZoXyFUnlDuFlQ2wgLV4XUAn9lhg
hFuCKITbvQBj+pgGtJW9lMuPLHtoYBNSqoJ+hwpXmiGY+/8u8bX1ZFUHAoGBAObb
nFAmRHIyNGL0DKBtsXIC5ncCVoWoA2e7LQLsIK48t/Y/umPkSaeuoNMKSLsNmnoA
BHi7R8BxDt5SMUc1Ee3S6T7KoTnDN+WifEPG5ZV5PquwYQzeISSQlPolM3594Tlr
jzFmh8YhWPMQLE0wFTXkORc2Gq3u7Cw/aZLtwPnDAoGAAkfVI9MNK3bK9/9jj6lH
OzGmfAQ5xL9xW3rhBPD8unbM97maYYRHJx1xqAViZRQP26zzAypact6rvcH36csA
FsjniYs4Shef01/pOwPoWkGtUT5MkwjnjdNGvdkqBYvlK2m8VDc12xwIA2W0o9i5
OZMhd+XPwwkdHnz2uH10mxcCgYAQ6zlaemN7xwgl1GL0gvWFOIcxY595riWJvaL/
2tROUK7ewi7j0UBApMCulstbwhR3KncpbfhFN0PysS1hXZdRyapEas9ED3WSQ8U9
pl7/BGK+bG/AZKsjJeF1L7LFa25NKf/VjAEZWSpOrfnBMmvrhi1U8SclZiQy3fbb
yMbixwKBgQD0N3QgaPivL/3WtuNfksseCQKcz6SzLo68VPpIHgol3zC+gaHDEoiX
zK53Pm5aSo3eyajzthUCIvfC2QpSyBETX5kxreNna71/XWhWMx3ZtT2d9zT4uSUt
wzJ7L4lAvQq7IpCrXMP8oApxVt22358x67pE+wjMivKkKEtokGzFRg==
-----END RSA PRIVATE KEY-----
16 changes: 16 additions & 0 deletions examples/postgres-diesel/certs/server-req.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-----BEGIN CERTIFICATE REQUEST-----
MIICkjCCAXoCAQAwTTELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0G
A1UEBwwGTG9uZG9uMRwwGgYDVQQDDBNteXNxbC1kaWVzZWwtc2VydmVyMIIBIjAN
BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4ERR/0NXqGaGERlrQ2ewwGdMR1rS
5OKgddlgPicMGHxBvYOvCUk7MggMBSDQePNUu7DR+fhQxZmRQCkJ5iHx9dSyjeY0
rK2SyExZSl+LY+B4rMbeU08gR0jAUD8KCkbRle3YQDauXqSVUVLwOXoThL59SntM
d/LA4oXXu2eT+z8qC9X4xwC602n7v+FrBhHwAEBbQj+cLSUcMmiNHKJ1wYD3QWLO
GnCgFDLYZEn2HPVTZuib6WWa419DJESyI92eT2LllYunCOd0bXiFxheg/k0tHKkB
YtHJeBn+/ALvASo7MW/7nSbcwttCYqdFSUnU4lbWv1TGflEBU2Q9wmCTVQIDAQAB
oAAwDQYJKoZIhvcNAQELBQADggEBAAP0fQjlLa5AlCMCjpoUMVr/vUwCJWnah3vN
nAbJbk1Pq1OgBG1+1iUf41OAFHeVmze/vGyJHYujgUBsgS8tBZmUDon9fVH8ny3Z
aBBbhvOgTMM5Z47zwGN1fZUqvZxth3SEs02jeECqiY1ZOtaluK13ui6Y6187arXH
o5qBx2gJSeerXCgitTMgqGRU9TgvQXZxQfbXNmdrwnI9Y4i763eKSFn+23T/9aQE
OBawz4hUCJn2vmfllMUlIX2AP0+XzuN2GoLTrBxAuYNKCT1xP5V90xl1uw9xIvKf
ebtgVTCUGGbdKTQEgYshoC1aOPIMTb3oBqSZHPNf+8IIkrSuRu4=
-----END CERTIFICATE REQUEST-----
12 changes: 12 additions & 0 deletions examples/postgres-diesel/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
postgres-14:
build:
context: .
dockerfile: Dockerfile
args:
VERSION: 14
ports:
- "127.0.0.1:5432:5432"
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
command: -c ssl=on -c ssl_cert_file=/var/lib/postgresql/certs/server-cert.pem -c ssl_key_file=/var/lib/postgresql/certs/server-key.pem -c ssl_ca_file=/var/lib/postgresql/certs/root-ca.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE users (
id VARCHAR(64) PRIMARY KEY NOT NULL,
email TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
13 changes: 13 additions & 0 deletions examples/postgres-diesel/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use database_schema::DatabaseSchemaBuilder;

#[tokio::main]
async fn main() -> Result<(), database_schema::Error> {
DatabaseSchemaBuilder::new()
//.connection_url("postgresql://[email protected]:5432/postgres")
.connection_url("postgresql://[email protected]:5432/postgres?sslmode=verify-ca&sslcert=certs/client-cert.pem&sslkey=certs/client-key.pem&sslrootcert=certs/root-ca.pem")
.migrations_dir("./migrations")?
.destination_path("./structure.sql")
.build()
.dump()
.await
}
63 changes: 63 additions & 0 deletions examples/postgres-diesel/structure.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
--
-- PostgreSQL database dump
--

-- Dumped from database version 14.9
-- Dumped by pg_dump version 14.9 (Homebrew)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: __diesel_schema_migrations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.__diesel_schema_migrations (
version character varying(50) NOT NULL,
run_on timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.users (
id character varying(64) NOT NULL,
email text NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


--
-- Name: __diesel_schema_migrations __diesel_schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.__diesel_schema_migrations
ADD CONSTRAINT __diesel_schema_migrations_pkey PRIMARY KEY (version);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- PostgreSQL database dump complete
--

0 comments on commit 2f08ee1

Please sign in to comment.