Skip to content

Commit 5d9feba

Browse files
committed
nicer demo page
1 parent 4cded80 commit 5d9feba

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

index.html

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<!DOCTYPE html>
22
<html>
3+
<title>sqldef</title>
4+
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
35
<head>
46
<meta charset="utf-8">
57
<script src="wasm_exec.js"></script>
68
<script src="sqldef_browser.js"></script>
79
<style>
810
body {
9-
font-family: sans-serif;
11+
font-family: 'Raleway', sans-serif;
12+
font-size: 20px;
1013
width: 960px;
1114
margin: 20px auto;
1215
color: #fff;
@@ -23,11 +26,28 @@
2326
pre {
2427
display: none;
2528
}
29+
#error {
30+
padding: 1em;
31+
background: IndianRed;
32+
color: DarkRed;
33+
border: 1px solid DarkRed;
34+
}
35+
a, a:visited, a:active {
36+
color: inherit;
37+
}
38+
a:hover {
39+
color: IndianRed;
40+
}
2641
</style>
2742
</head>
2843
<body>
44+
<h1>sqldef</h1>
45+
<img src="https://github.com/k0kubun/sqldef/raw/master/demo.gif" alt="screen capture" />
46+
<h2>What is it?</h2>
47+
<p>sqldef is a <a href="https://github.com/k0kubun/sqldef">CLI tool</a>, <a href="https://github.com/sqldef/sqldef.github.io">webasm library</a>, and <a href="https://github.com/sqldef/node-sqldef">nodejs tool/library</a> for diffing SQL schema. You can use it to manage migration of PostgreSQL and MySQL databases, using regular SQL DDL.</p>
48+
<h2>Demo</h2>
2949
<p>You can diff these 2 schemas:</p>
30-
50+
<pre id="error"></pre>
3151
<textarea id="inputA" rows="10">
3252
CREATE TABLE user (
3353
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
@@ -58,10 +78,17 @@
5878
const inputA = document.getElementById('inputA')
5979
const inputB = document.getElementById('inputB')
6080
const output = document.getElementById('output')
81+
const error = document.getElementById('error')
6182

6283
button.addEventListener('click', async () => {
6384
output.style.display = 'none'
64-
output.innerHTML = await window.sqldef(dbType.value, inputB.value, inputA.value)
85+
error.style.display = 'none'
86+
try {
87+
output.innerHTML = await window.sqldef(dbType.value, inputB.value, inputA.value)
88+
} catch (e) {
89+
error.style.display = 'block'
90+
error.innerHTML = e.message
91+
}
6592
output.style.display = 'block'
6693
})
6794
</script>

sqldef_browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ window.sqldef = async (dbType, desiredDDLs, currentDDLs) => {
1010
return new Promise((resolve, reject) => {
1111
_SQLDEF(dbType, desiredDDLs, currentDDLs, (err, ret) => {
1212
if (err) {
13-
return reject(err)
13+
return reject(new Error(err))
1414
}
1515
resolve(ret)
1616
})

0 commit comments

Comments
 (0)