-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialect_db2.go
More file actions
31 lines (29 loc) · 885 Bytes
/
dialect_db2.go
File metadata and controls
31 lines (29 loc) · 885 Bytes
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
// SPDX-FileCopyrightText: 2026 The DMorph contributors.
// SPDX-License-Identifier: MPL-2.0
package dmorph
// DialectDB2 returns a Dialect configured for DB2 databases.
func DialectDB2() BaseDialect {
return BaseDialect{
CreateTemplate: `
BEGIN
IF NOT EXISTS (
SELECT 1
FROM SYSIBM.SYSTABLES
WHERE NAME = '%s' AND TYPE = 'T'
)
THEN
CREATE TABLE "%s" (
id VARCHAR(255) PRIMARY KEY,
create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
END IF;
END`,
AppliedTemplate: `
SELECT id
FROM "%s"
ORDER BY create_ts ASC`,
RegisterTemplate: `
INSERT INTO "%s" (id)
VALUES (:id)`,
}
}