Skip to content

Commit 7d8c858

Browse files
committed
Replace sql with mariadb syntax
1 parent bbc2bc5 commit 7d8c858

File tree

10 files changed

+22
-34
lines changed

10 files changed

+22
-34
lines changed

database/domain.sql.go

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

database/favicon.sql.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

database/migrations/20240308125121_init.up.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
CREATE TABLE IF NOT EXISTS domains
22
(
3-
id INTEGER PRIMARY KEY AUTOINCREMENT,
3+
id INTEGER PRIMARY KEY AUTO_INCREMENT,
44
domain TEXT UNIQUE NOT NULL,
55
active BOOLEAN NOT NULL DEFAULT 1
66
);
77

88
CREATE TABLE IF NOT EXISTS favicons
99
(
10-
id INTEGER PRIMARY KEY AUTOINCREMENT,
11-
host VARCHAR NOT NULL,
12-
svg VARCHAR,
13-
png VARCHAR,
14-
ico VARCHAR
10+
id INTEGER PRIMARY KEY AUTO_INCREMENT,
11+
host TEXT NOT NULL,
12+
svg TEXT,
13+
png TEXT,
14+
ico TEXT
1515
);
1616

1717
CREATE TABLE IF NOT EXISTS routes
1818
(
19-
id INTEGER PRIMARY KEY AUTOINCREMENT,
19+
id INTEGER PRIMARY KEY AUTO_INCREMENT,
2020
source TEXT UNIQUE NOT NULL,
2121
destination TEXT NOT NULL,
2222
description TEXT NOT NULL,
@@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS routes
2626

2727
CREATE TABLE IF NOT EXISTS redirects
2828
(
29-
id INTEGER PRIMARY KEY AUTOINCREMENT,
29+
id INTEGER PRIMARY KEY AUTO_INCREMENT,
3030
source TEXT UNIQUE NOT NULL,
3131
destination TEXT NOT NULL,
3232
description TEXT NOT NULL,

database/models.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

database/queries/domain.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ FROM domains
44
WHERE active = 1;
55

66
-- name: AddDomain :exec
7-
INSERT
8-
OR
97
REPLACE
108
INTO domains (domain, active)
119
VALUES (?, ?);
1210

1311
-- name: DeleteDomain :exec
14-
INSERT
15-
OR
1612
REPLACE
1713
INTO domains(domain, active)
1814
VALUES (?, false);

database/queries/favicon.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ SELECT host, svg, png, ico
33
FROM favicons;
44

55
-- name: UpdateFaviconCache :exec
6-
INSERT OR
7-
REPLACE INTO favicons (host, svg, png, ico)
6+
REPLACE
7+
INTO favicons (host, svg, png, ico)
88
VALUES (?, ?, ?, ?);

database/queries/routing.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ SELECT source, destination, description, flags, code, active
1717
FROM redirects;
1818

1919
-- name: AddRoute :exec
20-
INSERT OR
2120
REPLACE
2221
INTO routes (source, destination, description, flags, active)
2322
VALUES (?, ?, ?, ?, ?);
2423

2524
-- name: AddRedirect :exec
26-
INSERT OR
2725
REPLACE
2826
INTO redirects (source, destination, description, flags, code, active)
2927
VALUES (?, ?, ?, ?, ?, ?);

database/routing.sql.go

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

target/redirect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Redirect struct {
1616
Dst string `json:"dst"` // redirect destination
1717
Desc string `json:"desc"` // description for admin panel use
1818
Flags Flags `json:"flags"` // extra flags
19-
Code int64 `json:"code"` // status code used to redirect
19+
Code int32 `json:"code"` // status code used to redirect
2020
}
2121

2222
type RedirectWithActive struct {

target/redirect_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestRedirect_ServeHTTP(t *testing.T) {
3535
res := httptest.NewRecorder()
3636
req := httptest.NewRequest(http.MethodGet, "https://www.example.com/hello/world", nil)
3737
i.ServeHTTP(res, req)
38-
assert.Equal(t, i.Code, int64(res.Code))
38+
assert.Equal(t, i.Code, int32(res.Code))
3939
assert.Equal(t, i.target, res.Header().Get("Location"))
4040
}
4141
}

0 commit comments

Comments
 (0)