-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
105 lines (96 loc) · 2.95 KB
/
index.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html>
<title>sqldef</title>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
<head>
<meta charset="utf-8">
<script src="wasm_exec.js"></script>
<script src="sqldef_browser.js"></script>
<style>
body {
font-family: 'Raleway', sans-serif;
font-size: 20px;
width: 960px;
margin: 20px auto;
color: #fff;
background: #000;
}
textarea, pre {
border: 1px solid #000;
background: #eee;
color: #000;
padding: 20px;
width: 100%;
}
pre {
display: none;
}
#error {
padding: 1em;
background: IndianRed;
color: DarkRed;
border: 1px solid DarkRed;
}
a, a:visited, a:active {
color: inherit;
}
a:hover {
color: IndianRed;
}
h4.schema-header {
margin-bottom: 0.7em;
}
</style>
</head>
<body>
<h1>sqldef</h1>
<img src="https://github.com/k0kubun/sqldef/raw/master/demo.gif" alt="screen capture" />
<h2>What is it?</h2>
<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>
<h2>Demo</h2>
<p>You can generate DDLs to update the DB schema:</p>
<div>
<select id="dbType">
<option value="mysql">MySQL</option>
<option value="postgres">PostgreSQL</option>
</select>
<button id="buttonDiff">DIFF</button>
</div>
<pre id="output"></pre>
<pre id="error"></pre>
<h4 class="schema-header">Current schema</h4>
<textarea id="inputA" rows="10">
CREATE TABLE user (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(128) DEFAULT 'konsumer'
) Engine=InnoDB DEFAULT CHARSET=utf8mb4;
</textarea>
<h4 class="schema-header">New schema</h4>
<textarea id="inputB" rows="10">
CREATE TABLE user (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(128) DEFAULT 'konsumer',
created_at DATETIME NOT NULL
) Engine=InnoDB DEFAULT CHARSET=utf8mb4;
</textarea>
<script>
const button = document.getElementById('buttonDiff')
const dbType = document.getElementById('dbType')
const inputA = document.getElementById('inputA')
const inputB = document.getElementById('inputB')
const output = document.getElementById('output')
const error = document.getElementById('error')
button.addEventListener('click', async () => {
output.style.display = 'none'
error.style.display = 'none'
try {
output.innerHTML = await window.sqldef(dbType.value, inputB.value, inputA.value)
output.style.display = 'block'
} catch (e) {
error.style.display = 'block'
error.innerHTML = e.message
}
})
</script>
</body>
</html>