-
Notifications
You must be signed in to change notification settings - Fork 2
/
migration.js
98 lines (97 loc) · 3.08 KB
/
migration.js
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
import crypto from 'node:crypto';
import lib from './lib/lib.js'
var migration = function(sqlite) {
var m = lib.migrate(sqlite)
m('create user table', `
create table user(
id INTEGER PRIMARY KEY AUTOINCREMENT,
uuid text not null UNIQUE,
username text not null UNIQUE,
password text not null,
expired_at INTEGER not null,
traffic_max INTEGER not null,
traffic_now INTEGER not null,
created_at INTEGER not null
)
`)
m('create brook table', `
create table brook(
id INTEGER PRIMARY KEY AUTOINCREMENT,
link text not null UNIQUE,
created_at INTEGER not null
)
`)
m('create task table', `
create table task(
id INTEGER PRIMARY KEY AUTOINCREMENT,
server text not null,
user text not null,
password text not null,
sshkey text not null,
serverlog_path text not null,
pid_path text not null,
created_at INTEGER not null
)
`)
m('create setting table', `
create table setting(
id INTEGER PRIMARY KEY AUTOINCREMENT,
k text not null UNIQUE,
v text not null
)
`)
var uuid = crypto.randomUUID().replaceAll('-', '')
m('init user api path setting', `
insert into setting(k, v) values('user_api_path', '${uuid}')
`)
m('init blockDomainList setting', `
insert into setting(k, v) values('blockDomainList', '360.com\n360.cn\nspeedtest.net\nspeedtest.cn\nfast.com\ntest.ustc.edu.cn\nspeed.neu.edu.cn\ntest6.ustc.edu.cn\nspeed.cloudflare.com\nspeed4.neu6.edu.cn\nspeedtest.ecnu.edu.cn\nspeed5.ntu.edu.tw\nspeed.net.virginia.edu\nspeedtest.tp.edu.tw\nspeedtest.jh.edu')
`)
m('init blockCIDR4List setting', `
insert into setting(k, v) values('blockCIDR4List', '127.0.0.1/32\n1.2.4.8/32')
`)
m('init blockCIDR6List setting', `
insert into setting(k, v) values('blockCIDR6List', '::1/128\nfd00::/8')
`)
m('init adminuser setting', `
insert into setting(k, v) values('adminuser', 'brook')
`)
m('init adminpassword setting', `
insert into setting(k, v) values('adminpassword', 'brook')
`)
m('init site name setting', `
insert into setting(k, v) values('site_name', 'Site Name')
`)
m('init signup setting', `
insert into setting(k, v) values('signup', 'true')
`)
m('init contact setting', `
insert into setting(k, v) values('contact', 'https://t.me/xxx')
`)
m('init hidden import for browser setting', `
insert into setting(k, v) values('import_dislike_browser', 'false')
`)
m('init site description setting', `
insert into setting(k, v) values('site_description', 'Site Description')
`)
m('init reCAPTCHAKey setting', `
insert into setting(k, v) values('reCAPTCHAKey', '')
`)
m('init reCAPTCHASecret setting', `
insert into setting(k, v) values('reCAPTCHASecret', '')
`)
m('create product table', `
create table product(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name text not null,
pay_url text not null
)
`)
m('init product 1', `
insert into product(name, pay_url) values('$3.5 for month (100G/month)', 'https://www.your-pay-url.com')
`)
m('init product 2', `
insert into product(name, pay_url) values('$30 for year (100G/month)', 'https://www.your-pay-url.com')
`)
}
export default migration;