feat: initialize project structure with core components, notifications, and database migrations
This commit is contained in:
commit
58ee357787
765 changed files with 168780 additions and 0 deletions
24
.editorconfig
Normal file
24
.editorconfig
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.yaml]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.yml]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.vue]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.go]
|
||||||
|
indent_style = tab
|
||||||
123
.eslintrc.js
Normal file
123
.eslintrc.js
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
module.exports = {
|
||||||
|
ignorePatterns: ["test/*.js", "server/modules/*", "src/util.js"],
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
commonjs: true,
|
||||||
|
es2020: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:vue/vue3-recommended",
|
||||||
|
"plugin:vue-scoped-css/vue3-recommended",
|
||||||
|
"plugin:jsdoc/recommended-error",
|
||||||
|
"prettier", // Disables ESLint formatting rules that conflict with Prettier
|
||||||
|
],
|
||||||
|
parser: "vue-eslint-parser",
|
||||||
|
parserOptions: {
|
||||||
|
parser: "@typescript-eslint/parser",
|
||||||
|
sourceType: "module",
|
||||||
|
requireConfigFile: false,
|
||||||
|
},
|
||||||
|
plugins: ["jsdoc", "@typescript-eslint"],
|
||||||
|
rules: {
|
||||||
|
yoda: "error",
|
||||||
|
eqeqeq: ["warn", "smart"],
|
||||||
|
camelcase: [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
properties: "never",
|
||||||
|
ignoreImports: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"no-unused-vars": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
args: "none",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"vue/max-attributes-per-line": "off",
|
||||||
|
"vue/singleline-html-element-content-newline": "off",
|
||||||
|
"vue/html-self-closing": "off",
|
||||||
|
"vue/require-component-is": "off", // not allow is="style" https://github.com/vuejs/eslint-plugin-vue/issues/462#issuecomment-430234675
|
||||||
|
"vue/attribute-hyphenation": "off", // This change noNL to "no-n-l" unexpectedly
|
||||||
|
"vue/multi-word-component-names": "off",
|
||||||
|
"vue-scoped-css/no-unused-selector": "warn",
|
||||||
|
curly: "error",
|
||||||
|
"no-var": "error",
|
||||||
|
"no-throw-literal": "error",
|
||||||
|
"no-constant-condition": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
checkLoops: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
//"no-console": "warn",
|
||||||
|
"no-extra-boolean-cast": "off",
|
||||||
|
"no-unneeded-ternary": "error",
|
||||||
|
//"prefer-template": "error",
|
||||||
|
"no-empty": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
allowEmptyCatch: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"no-control-regex": "off",
|
||||||
|
"one-var": ["error", "never"],
|
||||||
|
"max-statements-per-line": ["error", { max: 1 }],
|
||||||
|
"jsdoc/check-tag-names": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
definedTags: ["link"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"jsdoc/no-undefined-types": "off",
|
||||||
|
"jsdoc/no-defaults": ["error", { noOptionalParamNames: true }],
|
||||||
|
"jsdoc/require-throws": "warn",
|
||||||
|
"jsdoc/require-jsdoc": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
require: {
|
||||||
|
FunctionDeclaration: true,
|
||||||
|
MethodDefinition: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"jsdoc/no-blank-block-descriptions": "error",
|
||||||
|
"jsdoc/require-returns-description": "warn",
|
||||||
|
"jsdoc/require-returns-check": ["error", { reportMissingReturnForUndefinedTypes: false }],
|
||||||
|
"jsdoc/require-returns": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
forceRequireReturn: true,
|
||||||
|
forceReturnsWithAsync: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"jsdoc/require-param-type": "warn",
|
||||||
|
"jsdoc/require-param-description": "warn",
|
||||||
|
},
|
||||||
|
overrides: [
|
||||||
|
// Override for TypeScript
|
||||||
|
{
|
||||||
|
files: ["**/*.ts"],
|
||||||
|
extends: ["plugin:@typescript-eslint/recommended"],
|
||||||
|
rules: {
|
||||||
|
"jsdoc/require-returns-type": "off",
|
||||||
|
"jsdoc/require-returns": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
forceRequireReturn: false,
|
||||||
|
forceReturnsWithAsync: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"jsdoc/require-param-type": "off",
|
||||||
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"@typescript-eslint/ban-ts-comment": "off",
|
||||||
|
"prefer-const": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": "warn",
|
||||||
|
eqeqeq: "off",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
27
.gitignore
vendored
Normal file
27
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
.idea
|
||||||
|
|
||||||
|
/data
|
||||||
|
!/data/.gitkeep
|
||||||
|
/data*
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
/private
|
||||||
|
/out
|
||||||
|
/tmp
|
||||||
|
.env
|
||||||
|
|
||||||
|
/extra/healthcheck.exe
|
||||||
|
/extra/healthcheck
|
||||||
|
/extra/healthcheck-armv7
|
||||||
|
|
||||||
|
extra/exe-builder/bin
|
||||||
|
extra/exe-builder/obj
|
||||||
|
|
||||||
|
.vs
|
||||||
|
.vscode
|
||||||
|
.devcontainer
|
||||||
3
.npmrc
Normal file
3
.npmrc
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
legacy-peer-deps=true
|
||||||
|
min-release-age=7
|
||||||
|
min-release-age-exclude[]=redbean-node
|
||||||
2
.prettierignore
Normal file
2
.prettierignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# language files
|
||||||
|
src/lang/*.json
|
||||||
65
.prettierrc.js
Normal file
65
.prettierrc.js
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
* Prettier Configuration for Uptime Kuma
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* npm run fmt - Format all files (auto-runs in CI via autofix workflow)
|
||||||
|
* npm run fmt -- --check - Check formatting without making changes
|
||||||
|
*
|
||||||
|
* TIP: This formatter is automatically run in CI, so no need to worry about it
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
// Core formatting options - matching original ESLint rules
|
||||||
|
semi: true,
|
||||||
|
singleQuote: false,
|
||||||
|
trailingComma: "es5",
|
||||||
|
printWidth: 120,
|
||||||
|
tabWidth: 4,
|
||||||
|
useTabs: false,
|
||||||
|
endOfLine: "lf",
|
||||||
|
arrowParens: "always",
|
||||||
|
bracketSpacing: true,
|
||||||
|
bracketSameLine: false,
|
||||||
|
|
||||||
|
// Vue-specific settings
|
||||||
|
vueIndentScriptAndStyle: false,
|
||||||
|
singleAttributePerLine: false,
|
||||||
|
htmlWhitespaceSensitivity: "ignore", // More forgiving with whitespace in HTML
|
||||||
|
|
||||||
|
// Override settings for specific file types
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: "*.vue",
|
||||||
|
options: {
|
||||||
|
parser: "vue",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["*.json"],
|
||||||
|
options: {
|
||||||
|
tabWidth: 4,
|
||||||
|
trailingComma: "none",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["*.yml", "*.yaml"],
|
||||||
|
options: {
|
||||||
|
tabWidth: 2,
|
||||||
|
trailingComma: "none",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["src/icon.js"],
|
||||||
|
options: {
|
||||||
|
trailingComma: "all",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["*.md"],
|
||||||
|
options: {
|
||||||
|
printWidth: 100,
|
||||||
|
proseWrap: "preserve",
|
||||||
|
tabWidth: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
17
.stylelintrc
Normal file
17
.stylelintrc
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"stylelint-config-standard",
|
||||||
|
"stylelint-config-prettier"
|
||||||
|
],
|
||||||
|
"customSyntax": "postcss-html",
|
||||||
|
"rules": {
|
||||||
|
"no-descending-specificity": null,
|
||||||
|
"declaration-empty-line-before": null,
|
||||||
|
"alpha-value-notation": "number",
|
||||||
|
"color-function-notation": "legacy",
|
||||||
|
"shorthand-property-no-redundant-values": null,
|
||||||
|
"color-hex-length": null,
|
||||||
|
"declaration-block-no-redundant-longhand-properties": null,
|
||||||
|
"at-rule-no-unknown": null
|
||||||
|
}
|
||||||
|
}
|
||||||
6
.ws-context
Normal file
6
.ws-context
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"framework": "none",
|
||||||
|
"src/**": {
|
||||||
|
"framework": "vue"
|
||||||
|
}
|
||||||
|
}
|
||||||
566
CONTRIBUTING.md
Normal file
566
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,566 @@
|
||||||
|
# Project Info
|
||||||
|
|
||||||
|
First of all, I want to thank everyone who has submitted issues or shared pull
|
||||||
|
requests for Uptime Kuma. I never thought the GitHub community would be so nice!
|
||||||
|
Because of this, I also never thought that other people would actually read and
|
||||||
|
edit my code. Parts of the code are not very well-structured or commented, sorry
|
||||||
|
about that.
|
||||||
|
|
||||||
|
Before you start, please read our [Code of Conduct](CODE_OF_CONDUCT.md) to understand our community standards.
|
||||||
|
|
||||||
|
The project was created with `vite` and is written in `vue3`. Our backend
|
||||||
|
lives in the `server`-directory and mostly communicates via websockets.
|
||||||
|
Both frontend and backend share the same `package.json`.
|
||||||
|
|
||||||
|
For production, the frontend is built into the `dist`-directory and the server
|
||||||
|
(`express.js`) exposes the `dist` directory as the root of the endpoint. For
|
||||||
|
development, we run vite in development mode on another port.
|
||||||
|
|
||||||
|
## Directories
|
||||||
|
|
||||||
|
- `config` (dev config files)
|
||||||
|
- `data` (App data)
|
||||||
|
- `db` (Base database and migration scripts)
|
||||||
|
- `dist` (Frontend build)
|
||||||
|
- `docker` (Dockerfiles)
|
||||||
|
- `extra` (Extra useful scripts)
|
||||||
|
- `public` (Frontend resources for dev only)
|
||||||
|
- `server` (Server source code)
|
||||||
|
- `src` (Frontend source code)
|
||||||
|
- `test` (unit test)
|
||||||
|
|
||||||
|
## Can I Create a Pull Request for Uptime Kuma?
|
||||||
|
|
||||||
|
Whether or not you can create a pull request depends on the nature of your
|
||||||
|
contribution. We value both your time and our maintainers' time, so we want to
|
||||||
|
make sure it's spent efficiently.
|
||||||
|
|
||||||
|
If you're unsure about any process or step, you're probably not the only one
|
||||||
|
with that question—please feel free to ask. We're happy to help!
|
||||||
|
|
||||||
|
Different types of pull requests (PRs) may have different guidelines, so be sure
|
||||||
|
to review the appropriate one for your contribution.
|
||||||
|
|
||||||
|
- <details><summary><b>Security Fixes</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
Submitting security fixes is something that may put the community at risk.
|
||||||
|
Please read through our [security policy](SECURITY.md) and submit
|
||||||
|
vulnerabilities via an [advisory] + [issue] instead. We encourage you to
|
||||||
|
submit how to fix a vulnerability if you know how to, this is not required.
|
||||||
|
Following the security policy allows us to properly test, fix bugs. This
|
||||||
|
review allows us to notice, if there are any changes necessary to unrelated
|
||||||
|
parts like the documentation.
|
||||||
|
[**PLEASE SEE OUR SECURITY POLICY.**](SECURITY.md)
|
||||||
|
|
||||||
|
[advisory]: https://github.com/louislam/uptime-kuma/security/advisories/new
|
||||||
|
[issue]: https://github.com/louislam/uptime-kuma/issues/new?template=security_issue.yml
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary><b>Small, Non-Breaking Bug Fixes</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
If you come across a bug and think you can solve, we appreciate your work.
|
||||||
|
Please make sure that you follow these rules:
|
||||||
|
- keep the PR as small as possible, fix only one thing at a time => keeping it
|
||||||
|
reviewable
|
||||||
|
- test that your code does what you claim it does.
|
||||||
|
|
||||||
|
<sub>Because maintainer time is precious, junior maintainers may merge
|
||||||
|
uncontroversial PRs in this area.</sub>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary><b>Translations / Internationalisation (i18n)</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
Please add **all** strings that are translatable to `src/lang/en.json`. If translation keys are omitted, they cannot be translated. **Do not include any other languages in your initial pull request** (even if it is your mother tongue) to avoid merge conflicts between Weblate and `master`. Once your PR is merged into `master`, the strings can be translated by awesome people donating their language skills.
|
||||||
|
|
||||||
|
We use Weblate to localise this project into many languages. If you want to help translate Uptime Kuma into your language, please see [these instructions on how to translate using Weblate](https://github.com/louislam/uptime-kuma/blob/master/src/lang/README.md).
|
||||||
|
|
||||||
|
There are some cases where a change cannot be done directly in Weblate and requires a PR:
|
||||||
|
- A text may not yet be localisable. In this case, **adding a new language key** via `{{ $t("Translation key") }}` or [`<i18n-t keypath="Translation key">`](https://vue-i18n.intlify.dev/guide/advanced/component.html) might be necessary.
|
||||||
|
- Language keys need to be **added to `en.json`** to appear in Weblate. If this has not been done, a PR is appreciated.
|
||||||
|
- **Adding a new language** requires creating a new file. See [these instructions](https://github.com/louislam/uptime-kuma/blob/master/src/lang/README.md).
|
||||||
|
|
||||||
|
<sub>Because maintainer time is precious, junior maintainers may merge uncontroversial PRs in this area.</sub>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary><b>New Notification Providers</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
To set up a new notification provider these files need to be modified/created:
|
||||||
|
- `server/notification-providers/PROVIDER_NAME.js` is where the heart of the
|
||||||
|
notification provider lives.
|
||||||
|
|
||||||
|
- Both `monitorJSON` and `heartbeatJSON` can be `null` for some events. If
|
||||||
|
|
||||||
|
both are `null`, this is a general testing message, but if just
|
||||||
|
`heartbeatJSON` is `null` this is a certificate expiry.
|
||||||
|
|
||||||
|
- Please wrap the axios call into a
|
||||||
|
|
||||||
|
```js
|
||||||
|
try {
|
||||||
|
let result = await axios.post(...);
|
||||||
|
if (result.status === ...) ...
|
||||||
|
} catch (error) {
|
||||||
|
this.throwGeneralAxiosError(error);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- `server/notification.js` is where the backend of the notification provider
|
||||||
|
needs to be registered. _If you have an idea how we can skip this step, we
|
||||||
|
would love to hear about it ^^_
|
||||||
|
|
||||||
|
- `src/components/NotificationDialog.vue` you need to decide if the provider
|
||||||
|
is a regional or a global one and add it with a name to the respective list
|
||||||
|
|
||||||
|
- `src/components/notifications/PROVIDER_NAME.vue` is where the frontend of
|
||||||
|
each provider lives. Please make sure that you have:
|
||||||
|
|
||||||
|
- used `HiddenInput` for secret credentials
|
||||||
|
- included all the necessary helptexts/placeholder/.. to make sure the
|
||||||
|
|
||||||
|
notification provider is simple to setup for new users. - include all
|
||||||
|
translations (`{{ $t("Translation key") }}`,
|
||||||
|
[`i18n-t keypath="Translation key">`](https://vue-i18n.intlify.dev/guide/advanced/component.html))
|
||||||
|
in `src/lang/en.json` to enable our translators to translate this
|
||||||
|
- `src/components/notifications/index.js` is where the frontend of the
|
||||||
|
provider needs to be registered. _If you have an idea how we can skip this
|
||||||
|
step, we would love to hear about it ^^_
|
||||||
|
|
||||||
|
Offering notifications is close to the core of what we are as an uptime
|
||||||
|
monitor. Therefore, making sure that they work is also really important.
|
||||||
|
Because testing notification providers is quite time intensive, we mostly
|
||||||
|
offload this onto the person contributing a notification provider.
|
||||||
|
|
||||||
|
To make sure you have tested the notification provider, please include
|
||||||
|
screenshots of the following events in the pull-request description:
|
||||||
|
- `UP`/`DOWN`
|
||||||
|
- Certificate Expiry via <https://expired.badssl.com/>
|
||||||
|
- Domain Expiry via <https://google.com/> and a larger time set
|
||||||
|
- Testing (the test button on the notification provider setup page)
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
Using the following way to format this is encouraged:
|
||||||
|
|
||||||
|
```md
|
||||||
|
| Event | Before | After |
|
||||||
|
| ------------------ | --------------------- | -------------------- |
|
||||||
|
| `UP` |  |  |
|
||||||
|
| `DOWN` |  |  |
|
||||||
|
| Certificate-expiry |  |  |
|
||||||
|
| Domain-expiry |  |  |
|
||||||
|
| Testing |  |  |
|
||||||
|
```
|
||||||
|
|
||||||
|
<sub>Because maintainer time is precious, junior maintainers may merge
|
||||||
|
uncontroversial PRs in this area.</sub>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary><b>New Monitoring Types</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
To set up a new notification provider these files need to be modified/created:
|
||||||
|
- `server/monitor-types/MONITORING_TYPE.js` is the core of each monitor.
|
||||||
|
The `async check(...)`-function should:
|
||||||
|
- in the happy-path: set `heartbeat.msg` to a successful message and set `heartbeat.status = UP`
|
||||||
|
- in the unhappy-path: throw an `Error` for each fault that is detected with an actionable error message.
|
||||||
|
- NEVER set `heartbeat.status = DOWN` unless you want to explicitly ignore retries.
|
||||||
|
|
||||||
|
- `server/uptime-kuma-server.js` is where the monitoring backend needs to be
|
||||||
|
registered. _If you have an idea how we can skip this step, we would love to
|
||||||
|
hear about it ^^_
|
||||||
|
|
||||||
|
- `src/pages/EditMonitor.vue` is the shared frontend users interact with.
|
||||||
|
Please make sure that you have: - used `HiddenInput` for secret
|
||||||
|
credentials - included all the necessary helptexts/placeholder/.. to make
|
||||||
|
sure the notification provider is simple to setup for new users. - include
|
||||||
|
all translations (`{{ $t("Translation key") }}`,
|
||||||
|
[`<i18n-t keypath="Translation key">`](https://vue-i18n.intlify.dev/guide/advanced/component.html))
|
||||||
|
in `src/lang/en.json` to enable our translators to translate this
|
||||||
|
|
||||||
|
<sub>Because maintainer time is precious, junior maintainers may merge
|
||||||
|
uncontroversial PRs in this area.</sub>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary><b>New Features / Major Changes / Breaking Bugfixes</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
be sure to **create an empty draft pull request or open an issue, so we can
|
||||||
|
have a discussion first**.
|
||||||
|
This is especially important for large pull requests or when you don't know if it will be merged or not.
|
||||||
|
When adding new features, please also add tests to ensure your changes work as expected and to prevent future regressions.
|
||||||
|
|
||||||
|
<sub>Because of the large impact of this work, only senior maintainers may
|
||||||
|
merge PRs in this area. </sub>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary><b>As a First-Time Contributor</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
Contributing is easy and fun. We will guide you through the process:
|
||||||
|
1. **Fork** the [Uptime-Kuma repository](https://github.com/louislam/uptime-kuma/) and **clone** it to your local machine.
|
||||||
|
2. **Create a new branch** for your changes (e.g., `signal-notification-provider`).
|
||||||
|
3. **Make your changes** and **commit** them with a clear message.
|
||||||
|
4. **Push** your changes to your forked repository.
|
||||||
|
5. **Open a pull request** to the `master` branch of the Uptime Kuma repository.
|
||||||
|
- For large changes, please open a **draft pull request** first to discuss the changes with the maintainers.
|
||||||
|
6. **Provide a clear and concise description** of the changes you've made and link any related issues.
|
||||||
|
7. **Complete the PR checklist** and make sure all CI checks pass.
|
||||||
|
8. **Request a review** when your pull request is ready.
|
||||||
|
|
||||||
|
## When Can You Change the PR Status to "Ready for Review"?
|
||||||
|
|
||||||
|
A PR should remain in **draft status** until all tasks are completed.
|
||||||
|
Only change the status to **Ready for Review** when:
|
||||||
|
- You have implemented all planned changes.
|
||||||
|
- Your code is fully tested and ready for review.
|
||||||
|
- You have updated or created the necessary tests.
|
||||||
|
- You have verified that CI/CD checks pass successfully.
|
||||||
|
|
||||||
|
A volunteer maintainer will review your PR as soon as possible.
|
||||||
|
You can help us by reviewing other PRs or taking a look at open issues.
|
||||||
|
|
||||||
|
## The following rules are essential for making your PR mergeable
|
||||||
|
|
||||||
|
- Merging multiple issues by a huge PR is more difficult to review and causes
|
||||||
|
conflicts with other PRs. Please
|
||||||
|
- (if possible) **create one PR for one issue** or
|
||||||
|
- (if not possible) **explain which issues a PR addresses and why this PR
|
||||||
|
should not be broken apart**
|
||||||
|
|
||||||
|
- Make sure your **PR passes our continuous integration**. PRs will not be
|
||||||
|
merged unless all CI-Checks are green.
|
||||||
|
- **Breaking changes** (unless for a good reason and discussed beforehand) will
|
||||||
|
not get merged / not get merged quickly. Such changes require a major version
|
||||||
|
release.
|
||||||
|
- **Test your code** before submitting a PR. Buggy PRs will not be merged.
|
||||||
|
- Make sure the **UI/UX is close to Uptime Kuma**.
|
||||||
|
- **Think about the maintainability**: Don't add functionality that is
|
||||||
|
completely **out of scope**. Keep in mind that we need to be able to maintain
|
||||||
|
the functionality.
|
||||||
|
- Don't modify or delete existing logic without a valid reason.
|
||||||
|
- Don't convert existing code into other programming languages for no reason.
|
||||||
|
|
||||||
|
### Continuous Integration
|
||||||
|
|
||||||
|
All pull requests must pass our continuous integration checks. These checks include:
|
||||||
|
|
||||||
|
- **Linting**: We use ESLint and Stylelint for code quality checks. You can run the linter locally with `npm run lint`.
|
||||||
|
- **Formatting**: We use Prettier for code formatting. You can format your code with `npm run fmt` (or CI will do this for you)
|
||||||
|
- **Testing**: We use Playwright for end-to-end tests and have a suite of backend tests. You can run the tests locally with `npm test`.
|
||||||
|
|
||||||
|
I ([@louislam](https://github.com/louislam)) have the final say.
|
||||||
|
If your pull request does not meet my expectations, I will reject it, no matter how much time
|
||||||
|
you spent on it.
|
||||||
|
|
||||||
|
We will assign your pull request to a [milestone](https://github.com/louislam/uptime-kuma/milestones), if we plan to review and merge it.
|
||||||
|
|
||||||
|
Please don't rush or ask for an ETA.
|
||||||
|
We have to understand the pull request, make sure it has no breaking changes and stick to the vision of this project, especially for large pull requests.
|
||||||
|
|
||||||
|
## I'd Like to Work on an Issue. How Do I Do That?
|
||||||
|
|
||||||
|
We have found that assigning people to issues is unnecessary management
|
||||||
|
overhead. Instead, a short comment stating that you want to work on an issue is
|
||||||
|
appreciated, as it saves time for other developers. If you encounter any
|
||||||
|
problems during development, feel free to leave a comment describing what you
|
||||||
|
are stuck on. We are here to help.
|
||||||
|
|
||||||
|
## Project Style
|
||||||
|
|
||||||
|
I personally do not like something that requires a lot of configuration before
|
||||||
|
you can finally start the app. The goal is to make the Uptime Kuma installation
|
||||||
|
as easy as installing a mobile app.
|
||||||
|
|
||||||
|
- Easy to install for non-Docker users
|
||||||
|
- no native build dependency is needed (for `x86_64`/`arm64`)
|
||||||
|
- no extra configuration and
|
||||||
|
- no extra effort required to get it running
|
||||||
|
|
||||||
|
- Single container for Docker users
|
||||||
|
- no complex docker-compose file
|
||||||
|
- mapping the volume and exposing the port should be the only requirements
|
||||||
|
|
||||||
|
- Settings should be configurable in the frontend. Environment variables are
|
||||||
|
discouraged, unless it is related to startup such as `DATA_DIR`
|
||||||
|
- Easy to use
|
||||||
|
- The web UI styling should be consistent and nice
|
||||||
|
|
||||||
|
## Coding Styles
|
||||||
|
|
||||||
|
- 4 spaces indentation
|
||||||
|
- Follow `.editorconfig`
|
||||||
|
- Follow ESLint
|
||||||
|
- Methods and functions should be documented with JSDoc
|
||||||
|
|
||||||
|
## Name Conventions
|
||||||
|
|
||||||
|
- Javascript/Typescript: camelCaseType
|
||||||
|
- SQLite: snake_case (Underscore)
|
||||||
|
- CSS/SCSS: kebab-case (Dash)
|
||||||
|
|
||||||
|
## Tools
|
||||||
|
|
||||||
|
- [`Node.js`](https://nodejs.org/) >= 20.4.0
|
||||||
|
- [`npm`](https://www.npmjs.com/) >= 9.3
|
||||||
|
- [`git`](https://git-scm.com/)
|
||||||
|
- IDE that supports [`ESLint`](https://eslint.org/) and EditorConfig (I am using
|
||||||
|
[`IntelliJ IDEA`](https://www.jetbrains.com/idea/))
|
||||||
|
- A SQLite GUI tool (f.ex.
|
||||||
|
[`SQLite Expert Personal`](https://www.sqliteexpert.com/download.html) or
|
||||||
|
[`DBeaver Community`](https://dbeaver.io/download/))
|
||||||
|
|
||||||
|
## Git Branches
|
||||||
|
|
||||||
|
- `master`: 2.X.X development. If you want to add a new feature, your pull
|
||||||
|
request should base on this.
|
||||||
|
- `1.23.X`: 1.23.X development. If you want to fix a bug for v1 and v2, your
|
||||||
|
pull request should base on this.
|
||||||
|
- All other branches are unused, outdated or for dev.
|
||||||
|
|
||||||
|
## Install Dependencies for Development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm ci
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dev Server
|
||||||
|
|
||||||
|
We can start the frontend dev server and the backend dev server in one command.
|
||||||
|
|
||||||
|
Port `3000` and port `3001` will be used.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
But sometimes you may want to restart the server without restarting the
|
||||||
|
frontend. In that case, you can run these commands in two terminals:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run start-frontend-dev
|
||||||
|
npm run start-server-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Backend Server
|
||||||
|
|
||||||
|
It binds to `0.0.0.0:3001` by default.
|
||||||
|
|
||||||
|
The backend is an `express.js` server with `socket.io` integrated. It uses
|
||||||
|
`socket.io` to communicate with clients, and most server logic is encapsulated
|
||||||
|
in the `socket.io` handlers. `express.js` is also used to serve:
|
||||||
|
|
||||||
|
- as an entry point for redirecting to a status page or the dashboard
|
||||||
|
- the frontend built files (`index.html`, `*.js`, `*.css`, etc.)
|
||||||
|
- internal APIs of the status page
|
||||||
|
|
||||||
|
### Structure in `/server/`
|
||||||
|
|
||||||
|
- `jobs/` (Jobs that are running in another process)
|
||||||
|
- `model/` (Object model, auto-mapping to the database table name)
|
||||||
|
- `modules/` (Modified 3rd-party modules)
|
||||||
|
- `monitor_types/` (Monitor Types)
|
||||||
|
- `notification-providers/` (individual notification logic)
|
||||||
|
- `routers/` (Express Routers)
|
||||||
|
- `socket-handler/` (Socket.io Handlers)
|
||||||
|
- `server.js` (Server entry point)
|
||||||
|
- `uptime-kuma-server.js` (UptimeKumaServer class, main logic should be here,
|
||||||
|
but some still in `server.js`)
|
||||||
|
|
||||||
|
## Frontend Dev Server
|
||||||
|
|
||||||
|
It binds to `0.0.0.0:3000` by default. The frontend dev server is used for
|
||||||
|
development only.
|
||||||
|
|
||||||
|
For production, it is not used. It will be compiled to `dist` directory instead via `npm run build`.
|
||||||
|
|
||||||
|
You can use Vue.js devtools Chrome extension for debugging.
|
||||||
|
|
||||||
|
### Frontend Details
|
||||||
|
|
||||||
|
Uptime Kuma Frontend is a single page application (SPA). Most paths are handled
|
||||||
|
by Vue Router.
|
||||||
|
|
||||||
|
The router is in `src/router.js`
|
||||||
|
|
||||||
|
Most data in the frontend is stored at the root level, even though the router can navigate to different pages.
|
||||||
|
|
||||||
|
The data and socket logic are in `src/mixins/socket.js`.
|
||||||
|
|
||||||
|
## Database Migration
|
||||||
|
|
||||||
|
See: <https://github.com/louislam/uptime-kuma/tree/master/db/knex_migrations>
|
||||||
|
|
||||||
|
## Unit Test
|
||||||
|
|
||||||
|
To run unit tests, use the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
Both frontend and backend share the same `package.json`.
|
||||||
|
However, the frontend dependencies are eventually not used in the production environment, because it
|
||||||
|
is usually also baked into `dist` files. So:
|
||||||
|
|
||||||
|
- Frontend dependencies = "devDependencies"
|
||||||
|
- Examples: - `vue`, `chart.js`
|
||||||
|
- Backend dependencies = "dependencies"
|
||||||
|
- Examples: `socket.io`, `sqlite3`
|
||||||
|
- Development dependencies = "devDependencies"
|
||||||
|
- Examples: `eslint`, `sass`
|
||||||
|
|
||||||
|
### Update Dependencies
|
||||||
|
|
||||||
|
Since previously updating Vite 2.5.10 to 2.6.0 broke the application completely,
|
||||||
|
from now on, it should update the patch release version only.
|
||||||
|
|
||||||
|
Patch release = the third digit ([Semantic Versioning](https://semver.org/))
|
||||||
|
|
||||||
|
If for security / bug / other reasons, a library must be updated, breaking
|
||||||
|
changes need to be checked by the person proposing the change.
|
||||||
|
|
||||||
|
## Spelling & Grammar
|
||||||
|
|
||||||
|
Feel free to correct the spelling and grammar in the documentation or code.
|
||||||
|
English is not the native language of the maintainers.
|
||||||
|
|
||||||
|
## Wiki
|
||||||
|
|
||||||
|
Since there is no way to make a pull request to the wiki, I have set up another
|
||||||
|
repo to do that.
|
||||||
|
|
||||||
|
<https://github.com/louislam/uptime-kuma-wiki>
|
||||||
|
|
||||||
|
## Maintainer
|
||||||
|
|
||||||
|
### What is a maintainer and what are their roles?
|
||||||
|
|
||||||
|
This project has multiple maintainers who specialise in different areas.
|
||||||
|
Currently, there are 3 maintainers:
|
||||||
|
|
||||||
|
| Person | Role | Main Area |
|
||||||
|
| ----------------- | ----------------- | ---------------- |
|
||||||
|
| `@louislam` | senior maintainer | major features |
|
||||||
|
| `@chakflying` | junior maintainer | fixing bugs |
|
||||||
|
| `@commanderstorm` | junior maintainer | issue-management |
|
||||||
|
|
||||||
|
### Procedures
|
||||||
|
|
||||||
|
We have a few procedures we follow. These are documented here:
|
||||||
|
|
||||||
|
- <details><summary><b>Set up a Docker Builder</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
- amd64 using local.
|
||||||
|
- arm64 using remote arm64 cpu, as the emulator is too slow and can no longer
|
||||||
|
pass the `npm ci` command.
|
||||||
|
1. Add the public key to the remote server.
|
||||||
|
2. Add the remote context. The remote machine must be arm64 and installed
|
||||||
|
Docker CE.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker context create oracle-arm64-jp --docker "host=ssh://root@100.107.174.88"
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Create a new builder.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker buildx create --name kuma-builder --platform linux/amd64
|
||||||
|
docker buildx use kuma-builder
|
||||||
|
docker buildx inspect --bootstrap
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Append the remote context to the builder.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker buildx create --append --name kuma-builder --platform linux/arm64 oracle-arm64-jp
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Verify the builder and check if the builder is using `kuma-builder`.
|
||||||
|
`docker buildx inspect kuma-builder docker buildx ls`
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary><b>Release</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
1. Draft a release note
|
||||||
|
2. Make sure the repo is cleared
|
||||||
|
3. If the healthcheck is updated, remember to re-compile it:
|
||||||
|
`npm run build-docker-builder-go`
|
||||||
|
4. `npm run release-final` with env vars: `VERSION` and `GITHUB_TOKEN`
|
||||||
|
5. Wait until the `Press any key to continue`
|
||||||
|
6. `git push`
|
||||||
|
7. Publish the release note as `1.X.X`
|
||||||
|
8. Press any key to continue
|
||||||
|
9. Deploy to the demo server: `npm run deploy-demo-server`
|
||||||
|
|
||||||
|
These Items need to be checked:
|
||||||
|
- [ ] Check all tags is fine on
|
||||||
|
<https://hub.docker.com/r/louislam/uptime-kuma/tags>
|
||||||
|
- [ ] Try the Docker image with tag 1.X.X (Clean install / amd64 / arm64)
|
||||||
|
- [ ] Try clean installation with Node.js
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary><b>Release Beta</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
1. Draft a release note, check `This is a pre-release`
|
||||||
|
2. Make sure the repo is cleared
|
||||||
|
3. `npm run release-beta` with env vars: `VERSION` and `GITHUB_TOKEN`
|
||||||
|
4. Wait until the `Press any key to continue`
|
||||||
|
5. Publish the release note as `1.X.X-beta.X`
|
||||||
|
6. Press any key to continue
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary><b>Release Wiki</b> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
**Setup Repo**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/louislam/uptime-kuma-wiki.git
|
||||||
|
cd uptime-kuma-wiki
|
||||||
|
git remote add production https://github.com/louislam/uptime-kuma.wiki.git
|
||||||
|
```
|
||||||
|
|
||||||
|
**Push to Production Wiki**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git pull
|
||||||
|
git push production master
|
||||||
|
```
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- <details><summary>Change the base of a pull request such as <code>master</code> to <code>1.23.X</code> (click to expand)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git rebase --onto <new parent> <old parent>
|
||||||
|
```
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 Louis Lam
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
205
README.md
Normal file
205
README.md
Normal file
|
|
@ -0,0 +1,205 @@
|
||||||
|
<div align="center" width="100%">
|
||||||
|
<img src="./public/icon.svg" width="128" alt="Uptime Kuma Logo" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
# Uptime Kuma
|
||||||
|
|
||||||
|
Uptime Kuma is an easy-to-use self-hosted monitoring tool.
|
||||||
|
|
||||||
|
<a target="_blank" href="https://github.com/louislam/uptime-kuma"><img src="https://img.shields.io/github/stars/louislam/uptime-kuma?style=flat" /></a> <a target="_blank" href="https://hub.docker.com/r/louislam/uptime-kuma"><img src="https://img.shields.io/docker/pulls/louislam/uptime-kuma" /></a> <a target="_blank" href="https://hub.docker.com/r/louislam/uptime-kuma"><img src="https://img.shields.io/docker/v/louislam/uptime-kuma/2?label=docker%20image%20ver." /></a> <a target="_blank" href="https://github.com/louislam/uptime-kuma"><img src="https://img.shields.io/github/last-commit/louislam/uptime-kuma" /></a> <a target="_blank" href="https://opencollective.com/uptime-kuma"><img src="https://opencollective.com/uptime-kuma/total/badge.svg?label=Open%20Collective%20Backers&color=brightgreen" /></a>
|
||||||
|
[](https://github.com/sponsors/louislam) <a href="https://weblate.kuma.pet/projects/uptime-kuma/uptime-kuma/">
|
||||||
|
<img src="https://weblate.kuma.pet/widgets/uptime-kuma/-/svg-badge.svg" alt="Translation status" />
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<img src="https://user-images.githubusercontent.com/1336778/212262296-e6205815-ad62-488c-83ec-a5b0d0689f7c.jpg" width="700" alt="Uptime Kuma Dashboard Screenshot" />
|
||||||
|
|
||||||
|
## 🥔 Live Demo
|
||||||
|
|
||||||
|
Try it!
|
||||||
|
|
||||||
|
Demo Server (Location: Frankfurt - Germany): <https://demo.kuma.pet/start-demo>
|
||||||
|
|
||||||
|
It is a temporary live demo, all data will be deleted after 10 minutes. Sponsored by [Uptime Kuma Sponsors](https://github.com/louislam/uptime-kuma#%EF%B8%8F-sponsors).
|
||||||
|
|
||||||
|
## ⭐ Features
|
||||||
|
|
||||||
|
- Monitoring uptime for HTTP(s) / TCP / HTTP(s) Keyword / HTTP(s) Json Query / Websocket / Ping / DNS Record / Push / Steam Game Server / Docker Containers
|
||||||
|
- Fancy, Reactive, Fast UI/UX
|
||||||
|
- Notifications via Telegram, Discord, Gotify, Slack, Pushover, Email (SMTP), and [90+ notification services, click here for the full list](https://github.com/louislam/uptime-kuma/tree/master/src/components/notifications)
|
||||||
|
- 20-second intervals
|
||||||
|
- [Multi Languages](https://github.com/louislam/uptime-kuma/tree/master/src/lang)
|
||||||
|
- Multiple status pages
|
||||||
|
- Map status pages to specific domains
|
||||||
|
- Ping chart
|
||||||
|
- Certificate info
|
||||||
|
- Proxy support
|
||||||
|
- 2FA support
|
||||||
|
|
||||||
|
## 🔧 How to Install
|
||||||
|
|
||||||
|
### 🐳 Docker Compose
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir uptime-kuma
|
||||||
|
cd uptime-kuma
|
||||||
|
curl -o compose.yaml https://raw.githubusercontent.com/louislam/uptime-kuma/master/compose.yaml
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Uptime Kuma is now running on all network interfaces (e.g. http://localhost:3001 or http://your-ip:3001).
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> File Systems like **NFS** (Network File System) are **NOT** supported. Please map to a local directory or volume.
|
||||||
|
|
||||||
|
### 🐳 Docker Command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:2
|
||||||
|
```
|
||||||
|
|
||||||
|
Uptime Kuma is now running on all network interfaces (e.g. http://localhost:3001 or http://your-ip:3001).
|
||||||
|
|
||||||
|
If you want to limit exposure to localhost only:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run ... -p 127.0.0.1:3001:3001 ...
|
||||||
|
```
|
||||||
|
|
||||||
|
### 💪🏻 Non-Docker
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
|
||||||
|
- Platform
|
||||||
|
- ✅ Major Linux distros such as Debian, Ubuntu, Fedora and ArchLinux etc.
|
||||||
|
- ✅ Windows 10 (x64), Windows Server 2012 R2 (x64) or higher
|
||||||
|
- ❌ FreeBSD / OpenBSD / NetBSD
|
||||||
|
- ❌ Replit / Heroku
|
||||||
|
- [Node.js](https://nodejs.org/en/download/) >= 20.4
|
||||||
|
- [Git](https://git-scm.com/downloads)
|
||||||
|
- [pm2](https://pm2.keymetrics.io/) - For running Uptime Kuma in the background
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/louislam/uptime-kuma.git
|
||||||
|
cd uptime-kuma
|
||||||
|
npm run setup
|
||||||
|
|
||||||
|
# Option 1. Try it
|
||||||
|
node server/server.js
|
||||||
|
|
||||||
|
# (Recommended) Option 2. Run in the background using PM2
|
||||||
|
# Install PM2 if you don't have it:
|
||||||
|
npm install pm2 -g && pm2 install pm2-logrotate
|
||||||
|
|
||||||
|
# Start Server
|
||||||
|
pm2 start server/server.js --name uptime-kuma
|
||||||
|
```
|
||||||
|
|
||||||
|
Uptime Kuma is now running on all network interfaces (e.g. http://localhost:3001 or http://your-ip:3001).
|
||||||
|
|
||||||
|
More useful PM2 Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# If you want to see the current console output
|
||||||
|
pm2 monit
|
||||||
|
|
||||||
|
# If you want to add it to startup
|
||||||
|
pm2 startup && pm2 save
|
||||||
|
```
|
||||||
|
|
||||||
|
### Advanced Installation
|
||||||
|
|
||||||
|
If you need more options or need to browse via a reverse proxy, please read:
|
||||||
|
|
||||||
|
<https://github.com/louislam/uptime-kuma/wiki/%F0%9F%94%A7-How-to-Install>
|
||||||
|
|
||||||
|
## 🆙 How to Update
|
||||||
|
|
||||||
|
Please read:
|
||||||
|
|
||||||
|
<https://github.com/louislam/uptime-kuma/wiki/%F0%9F%86%99-How-to-Update>
|
||||||
|
|
||||||
|
## 🆕 What's Next?
|
||||||
|
|
||||||
|
I will assign requests/issues to the next milestone.
|
||||||
|
|
||||||
|
<https://github.com/louislam/uptime-kuma/milestones>
|
||||||
|
|
||||||
|
## ❤️ Sponsors
|
||||||
|
|
||||||
|
[](https://www.atlascloud.ai/?ref=UZCYBN)
|
||||||
|
|
||||||
|
Thank you so much! (GitHub Sponsors will be updated manually. OpenCollective sponsors will be updated automatically, the list will be cached by GitHub though. It may need some time to be updated)
|
||||||
|
|
||||||
|
<img src="https://uptime.kuma.pet/sponsors?v=6" alt="Uptime Kuma Sponsors" />
|
||||||
|
|
||||||
|
## 🖼 More Screenshots
|
||||||
|
|
||||||
|
Light Mode:
|
||||||
|
|
||||||
|
<img src="https://uptime.kuma.pet/img/light.jpg" width="512" alt="Uptime Kuma Light Mode Screenshot of how the Dashboard looks" />
|
||||||
|
|
||||||
|
Status Page:
|
||||||
|
|
||||||
|
<img src="https://user-images.githubusercontent.com/1336778/134628766-a3fe0981-0926-4285-ab46-891a21c3e4cb.png" width="512" alt="Uptime Kuma Status Page Screenshot" />
|
||||||
|
|
||||||
|
Settings Page:
|
||||||
|
|
||||||
|
<img src="https://louislam.net/uptimekuma/2.jpg" width="400" alt="Uptime Kuma Settings Page Screenshot" />
|
||||||
|
|
||||||
|
Telegram Notification Sample:
|
||||||
|
|
||||||
|
<img src="https://louislam.net/uptimekuma/3.jpg" width="400" alt="Uptime Kuma Telegram Notification Sample Screenshot" />
|
||||||
|
|
||||||
|
## Motivation
|
||||||
|
|
||||||
|
- I was looking for a self-hosted monitoring tool like "Uptime Robot", but it is hard to find a suitable one. One of the closest ones is statping. Unfortunately, it is not stable and no longer maintained.
|
||||||
|
- Wanted to build a fancy UI.
|
||||||
|
- Learn Vue 3 and vite.js.
|
||||||
|
- Show the power of Bootstrap 5.
|
||||||
|
- Try to use WebSocket with SPA instead of a REST API.
|
||||||
|
- Deploy my first Docker image to Docker Hub.
|
||||||
|
|
||||||
|
If you love this project, please consider giving it a ⭐.
|
||||||
|
|
||||||
|
## 🗣️ Discussion / Ask for Help
|
||||||
|
|
||||||
|
⚠️ For any general or technical questions, please don't send me an email, as I am unable to provide support in that manner. I will not respond if you ask questions there.
|
||||||
|
|
||||||
|
I recommend using Google, GitHub Issues, or Uptime Kuma's subreddit for finding answers to your question. If you cannot find the information you need, feel free to ask:
|
||||||
|
|
||||||
|
- [GitHub Issues](https://github.com/louislam/uptime-kuma/issues)
|
||||||
|
- [Subreddit (r/UptimeKuma)](https://www.reddit.com/r/UptimeKuma/)
|
||||||
|
|
||||||
|
My Reddit account: [u/louislamlam](https://reddit.com/u/louislamlam)
|
||||||
|
You can mention me if you ask a question on the subreddit.
|
||||||
|
|
||||||
|
## Contributions
|
||||||
|
|
||||||
|
### Create Pull Requests
|
||||||
|
|
||||||
|
Pull requests are awesome.
|
||||||
|
To keep reviews fast and effective, please make sure you’ve [read our pull request guidelines](https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma).
|
||||||
|
|
||||||
|
### Test Pull Requests
|
||||||
|
|
||||||
|
There are a lot of pull requests right now, but I don't have time to test them all.
|
||||||
|
|
||||||
|
If you want to help, you can check this:
|
||||||
|
<https://github.com/louislam/uptime-kuma/wiki/Test-Pull-Requests>
|
||||||
|
|
||||||
|
### Test Beta Version
|
||||||
|
|
||||||
|
Check out the latest beta release here: <https://github.com/louislam/uptime-kuma/releases>
|
||||||
|
|
||||||
|
### Bug Reports / Feature Requests
|
||||||
|
|
||||||
|
If you want to report a bug or request a new feature, feel free to open a [new issue](https://github.com/louislam/uptime-kuma/issues).
|
||||||
|
|
||||||
|
### Translations
|
||||||
|
|
||||||
|
If you want to translate Uptime Kuma into your language, please visit [Weblate Readme](https://github.com/louislam/uptime-kuma/blob/master/src/lang/README.md).
|
||||||
|
|
||||||
|
### Spelling & Grammar
|
||||||
|
|
||||||
|
Feel free to correct the grammar in the documentation or code.
|
||||||
|
My mother language is not English and my grammar is not that great.
|
||||||
47
SECURITY.md
Normal file
47
SECURITY.md
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Security Policy
|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
> Unfortunately, AI slop reports keep wasting my time. It will be closed and you will get banned immediately if you try to do that.
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
1. Please report security issues to
|
||||||
|
<https://github.com/louislam/uptime-kuma/security/advisories/new>.
|
||||||
|
2. Please also create an empty security issue to alert me, as GitHub Advisories
|
||||||
|
do not send a notification, I probably will miss it without this.
|
||||||
|
<https://github.com/louislam/uptime-kuma/issues/new?assignees=&labels=help&template=security.md>
|
||||||
|
|
||||||
|
- Do not report any upstream dependency issues / scan result by any tools. It will be closed immediately without explanations. Unless you have PoC to prove that the upstream issue affected Uptime Kuma.
|
||||||
|
- Do not use the public issue tracker or discuss it in public as it will cause
|
||||||
|
more damage.
|
||||||
|
- Do not report any SSRF issues.
|
||||||
|
|
||||||
|
## Do you accept other 3rd-party bug bounty platforms?
|
||||||
|
|
||||||
|
At this moment, I DO NOT accept other bug bounty platforms, because I am not
|
||||||
|
familiar with these platforms and someone has tried to send a phishing link to
|
||||||
|
me by doing this already. To minimize my own risk, please report through GitHub
|
||||||
|
Advisories only. I will ignore all 3rd-party bug bounty platforms emails.
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
### Uptime Kuma Versions
|
||||||
|
|
||||||
|
You should use or upgrade to the latest version of Uptime Kuma.
|
||||||
|
All versions are upgradable to the latest version.
|
||||||
|
|
||||||
|
### Upgradable Docker Tags
|
||||||
|
|
||||||
|
| Tag | Supported |
|
||||||
|
| --------------- | ------------------------------------------------------------------------------------- |
|
||||||
|
| 2 | :white_check_mark: |
|
||||||
|
| 2-slim | :white_check_mark: |
|
||||||
|
| next | :white_check_mark: |
|
||||||
|
| next-slim | :white_check_mark: |
|
||||||
|
| 2-rootless | :white_check_mark: |
|
||||||
|
| 2-slim-rootless | :white_check_mark: |
|
||||||
|
| 1 | [⚠️ Deprecated](https://github.com/louislam/uptime-kuma/wiki/Migration-From-v1-To-v2) |
|
||||||
|
| 1-debian | [⚠️ Deprecated](https://github.com/louislam/uptime-kuma/wiki/Migration-From-v1-To-v2) |
|
||||||
|
| latest | [⚠️ Deprecated](https://github.com/louislam/uptime-kuma/wiki/Migration-From-v1-To-v2) |
|
||||||
|
| debian | [⚠️ Deprecated](https://github.com/louislam/uptime-kuma/wiki/Migration-From-v1-To-v2) |
|
||||||
|
| All other tags | ❌ |
|
||||||
611
db/knex_init_db.js
Normal file
611
db/knex_init_db.js
Normal file
|
|
@ -0,0 +1,611 @@
|
||||||
|
const { R } = require("redbean-node");
|
||||||
|
const { log } = require("../src/util");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ⚠️⚠️⚠️⚠️⚠️⚠️ DO NOT ADD ANYTHING HERE!
|
||||||
|
* IF YOU NEED TO ADD FIELDS, ADD IT TO ./db/knex_migrations
|
||||||
|
* See ./db/knex_migrations/README.md for more information
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function createTables() {
|
||||||
|
log.info("mariadb", "Creating basic tables for MariaDB");
|
||||||
|
const knex = R.knex;
|
||||||
|
|
||||||
|
// TODO: Should check later if it is really the final patch sql file.
|
||||||
|
|
||||||
|
// docker_host
|
||||||
|
await knex.schema.createTable("docker_host", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.integer("user_id").unsigned().notNullable();
|
||||||
|
table.string("docker_daemon", 255);
|
||||||
|
table.string("docker_type", 255);
|
||||||
|
table.string("name", 255);
|
||||||
|
});
|
||||||
|
|
||||||
|
// group
|
||||||
|
await knex.schema.createTable("group", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("name", 255).notNullable();
|
||||||
|
table.datetime("created_date").notNullable().defaultTo(knex.fn.now());
|
||||||
|
table.boolean("public").notNullable().defaultTo(false);
|
||||||
|
table.boolean("active").notNullable().defaultTo(true);
|
||||||
|
table.integer("weight").notNullable().defaultTo(1000);
|
||||||
|
table.integer("status_page_id").unsigned();
|
||||||
|
});
|
||||||
|
|
||||||
|
// proxy
|
||||||
|
await knex.schema.createTable("proxy", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.integer("user_id").unsigned().notNullable();
|
||||||
|
table.string("protocol", 10).notNullable();
|
||||||
|
table.string("host", 255).notNullable();
|
||||||
|
table.smallint("port").notNullable(); // TODO: Maybe a issue with MariaDB, need migration to int
|
||||||
|
table.boolean("auth").notNullable();
|
||||||
|
table.string("username", 255).nullable();
|
||||||
|
table.string("password", 255).nullable();
|
||||||
|
table.boolean("active").notNullable().defaultTo(true);
|
||||||
|
table.boolean("default").notNullable().defaultTo(false);
|
||||||
|
table.datetime("created_date").notNullable().defaultTo(knex.fn.now());
|
||||||
|
|
||||||
|
table.index("user_id", "proxy_user_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
// user
|
||||||
|
await knex.schema.createTable("user", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("username", 255).notNullable().unique().collate("utf8_general_ci");
|
||||||
|
table.string("password", 255);
|
||||||
|
table.boolean("active").notNullable().defaultTo(true);
|
||||||
|
table.string("timezone", 150);
|
||||||
|
table.string("twofa_secret", 64);
|
||||||
|
table.boolean("twofa_status").notNullable().defaultTo(false);
|
||||||
|
table.string("twofa_last_token", 6);
|
||||||
|
});
|
||||||
|
|
||||||
|
// monitor
|
||||||
|
await knex.schema.createTable("monitor", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("name", 150);
|
||||||
|
table.boolean("active").notNullable().defaultTo(true);
|
||||||
|
table.integer("user_id").unsigned().references("id").inTable("user").onDelete("SET NULL").onUpdate("CASCADE");
|
||||||
|
table.integer("interval").notNullable().defaultTo(20);
|
||||||
|
table.text("url");
|
||||||
|
table.string("type", 20);
|
||||||
|
table.integer("weight").defaultTo(2000);
|
||||||
|
table.string("hostname", 255);
|
||||||
|
table.integer("port");
|
||||||
|
table.datetime("created_date").notNullable().defaultTo(knex.fn.now());
|
||||||
|
table.string("keyword", 255);
|
||||||
|
table.integer("maxretries").notNullable().defaultTo(0);
|
||||||
|
table.boolean("ignore_tls").notNullable().defaultTo(false);
|
||||||
|
table.boolean("upside_down").notNullable().defaultTo(false);
|
||||||
|
table.integer("maxredirects").notNullable().defaultTo(10);
|
||||||
|
table.text("accepted_statuscodes_json").notNullable().defaultTo('["200-299"]');
|
||||||
|
table.string("dns_resolve_type", 5);
|
||||||
|
table.string("dns_resolve_server", 255);
|
||||||
|
table.string("dns_last_result", 255);
|
||||||
|
table.integer("retry_interval").notNullable().defaultTo(0);
|
||||||
|
table.string("push_token", 20).defaultTo(null);
|
||||||
|
table.text("method").notNullable().defaultTo("GET");
|
||||||
|
table.text("body").defaultTo(null);
|
||||||
|
table.text("headers").defaultTo(null);
|
||||||
|
table.text("basic_auth_user").defaultTo(null);
|
||||||
|
table.text("basic_auth_pass").defaultTo(null);
|
||||||
|
table.integer("docker_host").unsigned().references("id").inTable("docker_host");
|
||||||
|
table.string("docker_container", 255);
|
||||||
|
table.integer("proxy_id").unsigned().references("id").inTable("proxy");
|
||||||
|
table.boolean("expiry_notification").defaultTo(true);
|
||||||
|
table.text("mqtt_topic");
|
||||||
|
table.string("mqtt_success_message", 255);
|
||||||
|
table.string("mqtt_username", 255);
|
||||||
|
table.string("mqtt_password", 255);
|
||||||
|
table.string("database_connection_string", 2000);
|
||||||
|
table.text("database_query");
|
||||||
|
table.string("auth_method", 250);
|
||||||
|
table.text("auth_domain");
|
||||||
|
table.text("auth_workstation");
|
||||||
|
table.string("grpc_url", 255).defaultTo(null);
|
||||||
|
table.text("grpc_protobuf").defaultTo(null);
|
||||||
|
table.text("grpc_body").defaultTo(null);
|
||||||
|
table.text("grpc_metadata").defaultTo(null);
|
||||||
|
table.text("grpc_method").defaultTo(null);
|
||||||
|
table.text("grpc_service_name").defaultTo(null);
|
||||||
|
table.boolean("grpc_enable_tls").notNullable().defaultTo(false);
|
||||||
|
table.string("radius_username", 255);
|
||||||
|
table.string("radius_password", 255);
|
||||||
|
table.string("radius_calling_station_id", 50);
|
||||||
|
table.string("radius_called_station_id", 50);
|
||||||
|
table.string("radius_secret", 255);
|
||||||
|
table.integer("resend_interval").notNullable().defaultTo(0);
|
||||||
|
table.integer("packet_size").notNullable().defaultTo(56);
|
||||||
|
table.string("game", 255);
|
||||||
|
});
|
||||||
|
|
||||||
|
// heartbeat
|
||||||
|
await knex.schema.createTable("heartbeat", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.boolean("important").notNullable().defaultTo(false);
|
||||||
|
table
|
||||||
|
.integer("monitor_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("monitor")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.smallint("status").notNullable();
|
||||||
|
|
||||||
|
table.text("msg");
|
||||||
|
table.datetime("time").notNullable();
|
||||||
|
table.integer("ping");
|
||||||
|
table.integer("duration").notNullable().defaultTo(0);
|
||||||
|
table.integer("down_count").notNullable().defaultTo(0);
|
||||||
|
|
||||||
|
table.index("important");
|
||||||
|
table.index(["monitor_id", "time"], "monitor_time_index");
|
||||||
|
table.index("monitor_id");
|
||||||
|
table.index(["monitor_id", "important", "time"], "monitor_important_time_index");
|
||||||
|
});
|
||||||
|
|
||||||
|
// incident
|
||||||
|
await knex.schema.createTable("incident", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("title", 255).notNullable();
|
||||||
|
table.text("content", 255).notNullable();
|
||||||
|
table.string("style", 30).notNullable().defaultTo("warning");
|
||||||
|
table.datetime("created_date").notNullable().defaultTo(knex.fn.now());
|
||||||
|
table.datetime("last_updated_date");
|
||||||
|
table.boolean("pin").notNullable().defaultTo(true);
|
||||||
|
table.boolean("active").notNullable().defaultTo(true);
|
||||||
|
table.integer("status_page_id").unsigned();
|
||||||
|
});
|
||||||
|
|
||||||
|
// maintenance
|
||||||
|
await knex.schema.createTable("maintenance", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("title", 150).notNullable();
|
||||||
|
table.text("description").notNullable();
|
||||||
|
table.integer("user_id").unsigned().references("id").inTable("user").onDelete("SET NULL").onUpdate("CASCADE");
|
||||||
|
table.boolean("active").notNullable().defaultTo(true);
|
||||||
|
table.string("strategy", 50).notNullable().defaultTo("single");
|
||||||
|
table.datetime("start_date");
|
||||||
|
table.datetime("end_date");
|
||||||
|
table.time("start_time");
|
||||||
|
table.time("end_time");
|
||||||
|
table.string("weekdays", 250).defaultTo("[]");
|
||||||
|
table.text("days_of_month").defaultTo("[]");
|
||||||
|
table.integer("interval_day");
|
||||||
|
|
||||||
|
table.index("active");
|
||||||
|
table.index(["strategy", "active"], "manual_active");
|
||||||
|
table.index("user_id", "maintenance_user_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
// status_page
|
||||||
|
await knex.schema.createTable("status_page", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("slug", 255).notNullable().unique().collate("utf8_general_ci");
|
||||||
|
table.string("title", 255).notNullable();
|
||||||
|
table.text("description");
|
||||||
|
table.string("icon", 255).notNullable();
|
||||||
|
table.string("theme", 30).notNullable();
|
||||||
|
table.boolean("published").notNullable().defaultTo(true);
|
||||||
|
table.boolean("search_engine_index").notNullable().defaultTo(true);
|
||||||
|
table.boolean("show_tags").notNullable().defaultTo(false);
|
||||||
|
table.string("password");
|
||||||
|
table.datetime("created_date").notNullable().defaultTo(knex.fn.now());
|
||||||
|
table.datetime("modified_date").notNullable().defaultTo(knex.fn.now());
|
||||||
|
table.text("footer_text");
|
||||||
|
table.text("custom_css");
|
||||||
|
table.boolean("show_powered_by").notNullable().defaultTo(true);
|
||||||
|
table.string("google_analytics_tag_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
// maintenance_status_page
|
||||||
|
await knex.schema.createTable("maintenance_status_page", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
|
||||||
|
table
|
||||||
|
.integer("status_page_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("status_page")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
|
||||||
|
table
|
||||||
|
.integer("maintenance_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("maintenance")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
});
|
||||||
|
|
||||||
|
// maintenance_timeslot
|
||||||
|
await knex.schema.createTable("maintenance_timeslot", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table
|
||||||
|
.integer("maintenance_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("maintenance")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.datetime("start_date").notNullable();
|
||||||
|
table.datetime("end_date");
|
||||||
|
table.boolean("generated_next").defaultTo(false);
|
||||||
|
|
||||||
|
table.index("maintenance_id");
|
||||||
|
table.index(["maintenance_id", "start_date", "end_date"], "active_timeslot_index");
|
||||||
|
table.index("generated_next", "generated_next_index");
|
||||||
|
});
|
||||||
|
|
||||||
|
// monitor_group
|
||||||
|
await knex.schema.createTable("monitor_group", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table
|
||||||
|
.integer("monitor_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("monitor")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table
|
||||||
|
.integer("group_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("group")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.integer("weight").notNullable().defaultTo(1000);
|
||||||
|
table.boolean("send_url").notNullable().defaultTo(false);
|
||||||
|
|
||||||
|
table.index(["monitor_id", "group_id"], "fk");
|
||||||
|
});
|
||||||
|
// monitor_maintenance
|
||||||
|
await knex.schema.createTable("monitor_maintenance", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table
|
||||||
|
.integer("monitor_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("monitor")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table
|
||||||
|
.integer("maintenance_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("maintenance")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
|
||||||
|
table.index("maintenance_id", "maintenance_id_index2");
|
||||||
|
table.index("monitor_id", "monitor_id_index");
|
||||||
|
});
|
||||||
|
|
||||||
|
// notification
|
||||||
|
await knex.schema.createTable("notification", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("name", 255);
|
||||||
|
table.boolean("active").notNullable().defaultTo(true);
|
||||||
|
table.integer("user_id").unsigned();
|
||||||
|
table.boolean("is_default").notNullable().defaultTo(false);
|
||||||
|
table.text("config", "longtext");
|
||||||
|
});
|
||||||
|
|
||||||
|
// monitor_notification
|
||||||
|
await knex.schema.createTable("monitor_notification", (table) => {
|
||||||
|
table.increments("id").unsigned(); // TODO: no auto increment????
|
||||||
|
table
|
||||||
|
.integer("monitor_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("monitor")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table
|
||||||
|
.integer("notification_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("notification")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
|
||||||
|
table.index(["monitor_id", "notification_id"], "monitor_notification_index");
|
||||||
|
});
|
||||||
|
|
||||||
|
// tag
|
||||||
|
await knex.schema.createTable("tag", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("name", 255).notNullable();
|
||||||
|
table.string("color", 255).notNullable();
|
||||||
|
table.datetime("created_date").notNullable().defaultTo(knex.fn.now());
|
||||||
|
});
|
||||||
|
|
||||||
|
// monitor_tag
|
||||||
|
await knex.schema.createTable("monitor_tag", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table
|
||||||
|
.integer("monitor_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("monitor")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table
|
||||||
|
.integer("tag_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("tag")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.text("value");
|
||||||
|
});
|
||||||
|
|
||||||
|
// monitor_tls_info
|
||||||
|
await knex.schema.createTable("monitor_tls_info", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table
|
||||||
|
.integer("monitor_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("monitor")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.text("info_json");
|
||||||
|
});
|
||||||
|
|
||||||
|
// notification_sent_history
|
||||||
|
await knex.schema.createTable("notification_sent_history", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("type", 50).notNullable();
|
||||||
|
table.integer("monitor_id").unsigned().notNullable();
|
||||||
|
table.integer("days").notNullable();
|
||||||
|
table.unique(["type", "monitor_id", "days"]);
|
||||||
|
table.index(["type", "monitor_id", "days"], "good_index");
|
||||||
|
});
|
||||||
|
|
||||||
|
// setting
|
||||||
|
await knex.schema.createTable("setting", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("key", 200).notNullable().unique().collate("utf8_general_ci");
|
||||||
|
table.text("value");
|
||||||
|
table.string("type", 20);
|
||||||
|
});
|
||||||
|
|
||||||
|
// status_page_cname
|
||||||
|
await knex.schema.createTable("status_page_cname", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table
|
||||||
|
.integer("status_page_id")
|
||||||
|
.unsigned()
|
||||||
|
.references("id")
|
||||||
|
.inTable("status_page")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.string("domain").notNullable().unique().collate("utf8_general_ci");
|
||||||
|
});
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* Converted Patch here
|
||||||
|
*********************/
|
||||||
|
|
||||||
|
// 2023-06-30-1348-http-body-encoding.js
|
||||||
|
// ALTER TABLE monitor ADD http_body_encoding VARCHAR(25);
|
||||||
|
// UPDATE monitor SET http_body_encoding = 'json' WHERE (type = 'http' or type = 'keyword') AND http_body_encoding IS NULL;
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.string("http_body_encoding", 25);
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex("monitor")
|
||||||
|
.where(function () {
|
||||||
|
this.where("type", "http").orWhere("type", "keyword");
|
||||||
|
})
|
||||||
|
.whereNull("http_body_encoding")
|
||||||
|
.update({
|
||||||
|
http_body_encoding: "json",
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2023-06-30-1354-add-description-monitor.js
|
||||||
|
// ALTER TABLE monitor ADD description TEXT default null;
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.text("description").defaultTo(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2023-06-30-1357-api-key-table.js
|
||||||
|
/*
|
||||||
|
CREATE TABLE [api_key] (
|
||||||
|
[id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
[key] VARCHAR(255) NOT NULL,
|
||||||
|
[name] VARCHAR(255) NOT NULL,
|
||||||
|
[user_id] INTEGER NOT NULL,
|
||||||
|
[created_date] DATETIME DEFAULT (DATETIME('now')) NOT NULL,
|
||||||
|
[active] BOOLEAN DEFAULT 1 NOT NULL,
|
||||||
|
[expires] DATETIME DEFAULT NULL,
|
||||||
|
CONSTRAINT FK_user FOREIGN KEY ([user_id]) REFERENCES [user]([id]) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
await knex.schema.createTable("api_key", function (table) {
|
||||||
|
table.increments("id").primary();
|
||||||
|
table.string("key", 255).notNullable();
|
||||||
|
table.string("name", 255).notNullable();
|
||||||
|
table
|
||||||
|
.integer("user_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("user")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.dateTime("created_date").defaultTo(knex.fn.now()).notNullable();
|
||||||
|
table.boolean("active").defaultTo(1).notNullable();
|
||||||
|
table.dateTime("expires").defaultTo(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2023-06-30-1400-monitor-tls.js
|
||||||
|
/*
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD tls_ca TEXT default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD tls_cert TEXT default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD tls_key TEXT default null;
|
||||||
|
*/
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.text("tls_ca").defaultTo(null);
|
||||||
|
table.text("tls_cert").defaultTo(null);
|
||||||
|
table.text("tls_key").defaultTo(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2023-06-30-1401-maintenance-cron.js
|
||||||
|
/*
|
||||||
|
-- 999 characters. https://stackoverflow.com/questions/46134830/maximum-length-for-cron-job
|
||||||
|
DROP TABLE maintenance_timeslot;
|
||||||
|
ALTER TABLE maintenance ADD cron TEXT;
|
||||||
|
ALTER TABLE maintenance ADD timezone VARCHAR(255);
|
||||||
|
ALTER TABLE maintenance ADD duration INTEGER;
|
||||||
|
*/
|
||||||
|
await knex.schema.dropTableIfExists("maintenance_timeslot").table("maintenance", function (table) {
|
||||||
|
table.text("cron");
|
||||||
|
table.string("timezone", 255);
|
||||||
|
table.integer("duration");
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2023-06-30-1413-add-parent-monitor.js.
|
||||||
|
/*
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD parent INTEGER REFERENCES [monitor] ([id]) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
*/
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.integer("parent").unsigned().references("id").inTable("monitor").onDelete("SET NULL").onUpdate("CASCADE");
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
patch-add-invert-keyword.sql
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD invert_keyword BOOLEAN default 0 not null;
|
||||||
|
*/
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.boolean("invert_keyword").defaultTo(0).notNullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
patch-added-json-query.sql
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD json_path TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD expected_value VARCHAR(255);
|
||||||
|
*/
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.text("json_path");
|
||||||
|
table.string("expected_value", 255);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
patch-added-kafka-producer.sql
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_topic VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_brokers TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_ssl INTEGER;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_allow_auto_topic_creation VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_sasl_options TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_message TEXT;
|
||||||
|
*/
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.string("kafka_producer_topic", 255);
|
||||||
|
table.text("kafka_producer_brokers");
|
||||||
|
|
||||||
|
// patch-fix-kafka-producer-booleans.sql
|
||||||
|
table.boolean("kafka_producer_ssl").defaultTo(0).notNullable();
|
||||||
|
table.boolean("kafka_producer_allow_auto_topic_creation").defaultTo(0).notNullable();
|
||||||
|
|
||||||
|
table.text("kafka_producer_sasl_options");
|
||||||
|
table.text("kafka_producer_message");
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
patch-add-certificate-expiry-status-page.sql
|
||||||
|
ALTER TABLE status_page
|
||||||
|
ADD show_certificate_expiry BOOLEAN default 0 NOT NULL;
|
||||||
|
*/
|
||||||
|
await knex.schema.table("status_page", function (table) {
|
||||||
|
table.boolean("show_certificate_expiry").defaultTo(0).notNullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
patch-monitor-oauth-cc.sql
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD oauth_client_id TEXT default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD oauth_client_secret TEXT default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD oauth_token_url TEXT default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD oauth_scopes TEXT default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD oauth_auth_method TEXT default null;
|
||||||
|
*/
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.text("oauth_client_id").defaultTo(null);
|
||||||
|
table.text("oauth_client_secret").defaultTo(null);
|
||||||
|
table.text("oauth_token_url").defaultTo(null);
|
||||||
|
table.text("oauth_scopes").defaultTo(null);
|
||||||
|
table.text("oauth_auth_method").defaultTo(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
patch-add-timeout-monitor.sql
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD timeout DOUBLE default 0 not null;
|
||||||
|
*/
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.double("timeout").defaultTo(0).notNullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
patch-add-gamedig-given-port.sql
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD gamedig_given_port_only BOOLEAN default 1 not null;
|
||||||
|
*/
|
||||||
|
await knex.schema.table("monitor", function (table) {
|
||||||
|
table.boolean("gamedig_given_port_only").defaultTo(1).notNullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
log.info("mariadb", "Created basic tables for MariaDB");
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
createTables,
|
||||||
|
};
|
||||||
43
db/knex_migrations/2023-08-16-0000-create-uptime.js
Normal file
43
db/knex_migrations/2023-08-16-0000-create-uptime.js
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.createTable("stat_minutely", function (table) {
|
||||||
|
table.increments("id");
|
||||||
|
table.comment("This table contains the minutely aggregate statistics for each monitor");
|
||||||
|
table
|
||||||
|
.integer("monitor_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("monitor")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.integer("timestamp").notNullable().comment("Unix timestamp rounded down to the nearest minute");
|
||||||
|
table.float("ping").notNullable().comment("Average ping in milliseconds");
|
||||||
|
table.smallint("up").notNullable();
|
||||||
|
table.smallint("down").notNullable();
|
||||||
|
|
||||||
|
table.unique(["monitor_id", "timestamp"]);
|
||||||
|
})
|
||||||
|
.createTable("stat_daily", function (table) {
|
||||||
|
table.increments("id");
|
||||||
|
table.comment("This table contains the daily aggregate statistics for each monitor");
|
||||||
|
table
|
||||||
|
.integer("monitor_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("monitor")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.integer("timestamp").notNullable().comment("Unix timestamp rounded down to the nearest day");
|
||||||
|
table.float("ping").notNullable().comment("Average ping in milliseconds");
|
||||||
|
table.smallint("up").notNullable();
|
||||||
|
table.smallint("down").notNullable();
|
||||||
|
|
||||||
|
table.unique(["monitor_id", "timestamp"]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.dropTable("stat_minutely").dropTable("stat_daily");
|
||||||
|
};
|
||||||
13
db/knex_migrations/2023-08-18-0301-heartbeat.js
Normal file
13
db/knex_migrations/2023-08-18-0301-heartbeat.js
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Add new column heartbeat.end_time
|
||||||
|
return knex.schema.alterTable("heartbeat", function (table) {
|
||||||
|
table.datetime("end_time").nullable().defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
// Rename heartbeat.start_time to heartbeat.time
|
||||||
|
return knex.schema.alterTable("heartbeat", function (table) {
|
||||||
|
table.dropColumn("end_time");
|
||||||
|
});
|
||||||
|
};
|
||||||
12
db/knex_migrations/2023-09-29-0000-heartbeat-retires.js
Normal file
12
db/knex_migrations/2023-09-29-0000-heartbeat-retires.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Add new column heartbeat.retries
|
||||||
|
return knex.schema.alterTable("heartbeat", function (table) {
|
||||||
|
table.integer("retries").notNullable().defaultTo(0);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("heartbeat", function (table) {
|
||||||
|
table.dropColumn("retries");
|
||||||
|
});
|
||||||
|
};
|
||||||
13
db/knex_migrations/2023-10-08-0000-mqtt-query.js
Normal file
13
db/knex_migrations/2023-10-08-0000-mqtt-query.js
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Add new column monitor.mqtt_check_type
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("mqtt_check_type", 255).notNullable().defaultTo("keyword");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
// Drop column monitor.mqtt_check_type
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("mqtt_check_type");
|
||||||
|
});
|
||||||
|
};
|
||||||
12
db/knex_migrations/2023-10-11-1915-push-token-to-32.js
Normal file
12
db/knex_migrations/2023-10-11-1915-push-token-to-32.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// update monitor.push_token to 32 length
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("push_token", 32).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("push_token", 20).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
26
db/knex_migrations/2023-10-16-0000-create-remote-browsers.js
Normal file
26
db/knex_migrations/2023-10-16-0000-create-remote-browsers.js
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.createTable("remote_browser", function (table) {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("name", 255).notNullable();
|
||||||
|
table.string("url", 255).notNullable();
|
||||||
|
table.integer("user_id").unsigned();
|
||||||
|
})
|
||||||
|
.alterTable("monitor", function (table) {
|
||||||
|
// Add new column monitor.remote_browser
|
||||||
|
table
|
||||||
|
.integer("remote_browser")
|
||||||
|
.nullable()
|
||||||
|
.defaultTo(null)
|
||||||
|
.unsigned()
|
||||||
|
.index()
|
||||||
|
.references("id")
|
||||||
|
.inTable("remote_browser");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.dropTable("remote_browser").alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("remote_browser");
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2023-12-20-0000-alter-status-page.js
Normal file
11
db/knex_migrations/2023-12-20-0000-alter-status-page.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.integer("auto_refresh_interval").defaultTo(300).unsigned();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.dropColumn("auto_refresh_interval");
|
||||||
|
});
|
||||||
|
};
|
||||||
39
db/knex_migrations/2023-12-21-0000-stat-ping-min-max.js
Normal file
39
db/knex_migrations/2023-12-21-0000-stat-ping-min-max.js
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("stat_daily", function (table) {
|
||||||
|
table
|
||||||
|
.float("ping_min")
|
||||||
|
.notNullable()
|
||||||
|
.defaultTo(0)
|
||||||
|
.comment("Minimum ping during this period in milliseconds");
|
||||||
|
table
|
||||||
|
.float("ping_max")
|
||||||
|
.notNullable()
|
||||||
|
.defaultTo(0)
|
||||||
|
.comment("Maximum ping during this period in milliseconds");
|
||||||
|
})
|
||||||
|
.alterTable("stat_minutely", function (table) {
|
||||||
|
table
|
||||||
|
.float("ping_min")
|
||||||
|
.notNullable()
|
||||||
|
.defaultTo(0)
|
||||||
|
.comment("Minimum ping during this period in milliseconds");
|
||||||
|
table
|
||||||
|
.float("ping_max")
|
||||||
|
.notNullable()
|
||||||
|
.defaultTo(0)
|
||||||
|
.comment("Maximum ping during this period in milliseconds");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("stat_daily", function (table) {
|
||||||
|
table.dropColumn("ping_min");
|
||||||
|
table.dropColumn("ping_max");
|
||||||
|
})
|
||||||
|
.alterTable("stat_minutely", function (table) {
|
||||||
|
table.dropColumn("ping_min");
|
||||||
|
table.dropColumn("ping_max");
|
||||||
|
});
|
||||||
|
};
|
||||||
26
db/knex_migrations/2023-12-22-0000-hourly-uptime.js
Normal file
26
db/knex_migrations/2023-12-22-0000-hourly-uptime.js
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.createTable("stat_hourly", function (table) {
|
||||||
|
table.increments("id");
|
||||||
|
table.comment("This table contains the hourly aggregate statistics for each monitor");
|
||||||
|
table
|
||||||
|
.integer("monitor_id")
|
||||||
|
.unsigned()
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("monitor")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
table.integer("timestamp").notNullable().comment("Unix timestamp rounded down to the nearest hour");
|
||||||
|
table.float("ping").notNullable().comment("Average ping in milliseconds");
|
||||||
|
table.float("ping_min").notNullable().defaultTo(0).comment("Minimum ping during this period in milliseconds");
|
||||||
|
table.float("ping_max").notNullable().defaultTo(0).comment("Maximum ping during this period in milliseconds");
|
||||||
|
table.smallint("up").notNullable();
|
||||||
|
table.smallint("down").notNullable();
|
||||||
|
|
||||||
|
table.unique(["monitor_id", "timestamp"]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.dropTable("stat_hourly");
|
||||||
|
};
|
||||||
25
db/knex_migrations/2024-01-22-0000-stats-extras.js
Normal file
25
db/knex_migrations/2024-01-22-0000-stats-extras.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("stat_daily", function (table) {
|
||||||
|
table.text("extras").defaultTo(null).comment("Extra statistics during this time period");
|
||||||
|
})
|
||||||
|
.alterTable("stat_minutely", function (table) {
|
||||||
|
table.text("extras").defaultTo(null).comment("Extra statistics during this time period");
|
||||||
|
})
|
||||||
|
.alterTable("stat_hourly", function (table) {
|
||||||
|
table.text("extras").defaultTo(null).comment("Extra statistics during this time period");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("stat_daily", function (table) {
|
||||||
|
table.dropColumn("extras");
|
||||||
|
})
|
||||||
|
.alterTable("stat_minutely", function (table) {
|
||||||
|
table.dropColumn("extras");
|
||||||
|
})
|
||||||
|
.alterTable("stat_hourly", function (table) {
|
||||||
|
table.dropColumn("extras");
|
||||||
|
});
|
||||||
|
};
|
||||||
15
db/knex_migrations/2024-04-26-0000-snmp-monitor.js
Normal file
15
db/knex_migrations/2024-04-26-0000-snmp-monitor.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("snmp_oid").defaultTo(null);
|
||||||
|
table.enum("snmp_version", ["1", "2c", "3"]).defaultTo("2c");
|
||||||
|
table.string("json_path_operator").defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("snmp_oid");
|
||||||
|
table.dropColumn("snmp_version");
|
||||||
|
table.dropColumn("json_path_operator");
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2024-08-24-000-add-cache-bust.js
Normal file
11
db/knex_migrations/2024-08-24-000-add-cache-bust.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.boolean("cache_bust").notNullable().defaultTo(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("cache_bust");
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2024-08-24-0000-conditions.js
Normal file
11
db/knex_migrations/2024-08-24-0000-conditions.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.text("conditions").notNullable().defaultTo("[]");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("conditions");
|
||||||
|
});
|
||||||
|
};
|
||||||
15
db/knex_migrations/2024-10-1315-rabbitmq-monitor.js
Normal file
15
db/knex_migrations/2024-10-1315-rabbitmq-monitor.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.text("rabbitmq_nodes");
|
||||||
|
table.string("rabbitmq_username");
|
||||||
|
table.string("rabbitmq_password");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("rabbitmq_nodes");
|
||||||
|
table.dropColumn("rabbitmq_username");
|
||||||
|
table.dropColumn("rabbitmq_password");
|
||||||
|
});
|
||||||
|
};
|
||||||
7
db/knex_migrations/2024-10-31-0000-fix-snmp-monitor.js
Normal file
7
db/knex_migrations/2024-10-31-0000-fix-snmp-monitor.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex("monitor").whereNull("json_path_operator").update("json_path_operator", "==");
|
||||||
|
};
|
||||||
|
exports.down = function (knex) {
|
||||||
|
// changing the json_path_operator back to null for all "==" is not possible anymore
|
||||||
|
// we have lost the context which fields have been set explicitly in >= v2.0 and which would need to be reverted
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Update info_json column to LONGTEXT mainly for MariaDB
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor_tls_info", function (table) {
|
||||||
|
table.text("info_json", "longtext").alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor_tls_info", function (table) {
|
||||||
|
table.text("info_json", "text").alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2025-01-01-0000-add-smtp.js
Normal file
11
db/knex_migrations/2025-01-01-0000-add-smtp.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("smtp_security").defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("smtp_security");
|
||||||
|
});
|
||||||
|
};
|
||||||
14
db/knex_migrations/2025-02-15-2312-add-wstest.js
Normal file
14
db/knex_migrations/2025-02-15-2312-add-wstest.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Add websocket ignore headers and websocket subprotocol
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.boolean("ws_ignore_sec_websocket_accept_header").notNullable().defaultTo(false);
|
||||||
|
table.string("ws_subprotocol", 255).notNullable().defaultTo("");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("ws_ignore_sec_websocket_accept_header");
|
||||||
|
table.dropColumn("ws_subprotocol");
|
||||||
|
});
|
||||||
|
};
|
||||||
23
db/knex_migrations/2025-02-17-2142-generalize-analytics.js
Normal file
23
db/knex_migrations/2025-02-17-2142-generalize-analytics.js
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Update status_page table to generalize analytics fields
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("status_page", function (table) {
|
||||||
|
table.renameColumn("google_analytics_tag_id", "analytics_id");
|
||||||
|
table.string("analytics_script_url");
|
||||||
|
table.enu("analytics_type", ["google", "umami", "plausible", "matomo"]).defaultTo(null);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
// After a successful migration, add google as default for previous pages
|
||||||
|
knex("status_page").whereNotNull("analytics_id").update({
|
||||||
|
analytics_type: "google",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.renameColumn("analytics_id", "google_analytics_tag_id");
|
||||||
|
table.dropColumn("analytics_script_url");
|
||||||
|
table.dropColumn("analytics_type");
|
||||||
|
});
|
||||||
|
};
|
||||||
21
db/knex_migrations/2025-03-04-0000-ping-advanced-options.js
Normal file
21
db/knex_migrations/2025-03-04-0000-ping-advanced-options.js
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
/* SQL:
|
||||||
|
ALTER TABLE monitor ADD ping_count INTEGER default 1 not null;
|
||||||
|
ALTER TABLE monitor ADD ping_numeric BOOLEAN default true not null;
|
||||||
|
ALTER TABLE monitor ADD ping_per_request_timeout INTEGER default 2 not null;
|
||||||
|
*/
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Add new columns to table monitor
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.integer("ping_count").defaultTo(1).notNullable();
|
||||||
|
table.boolean("ping_numeric").defaultTo(true).notNullable();
|
||||||
|
table.integer("ping_per_request_timeout").defaultTo(2).notNullable();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("ping_count");
|
||||||
|
table.dropColumn("ping_numeric");
|
||||||
|
table.dropColumn("ping_per_request_timeout");
|
||||||
|
});
|
||||||
|
};
|
||||||
12
db/knex_migrations/2025-03-25-0127-fix-5721.js
Normal file
12
db/knex_migrations/2025-03-25-0127-fix-5721.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Fix #5721: Change proxy port column type to integer to support larger port numbers
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("proxy", function (table) {
|
||||||
|
table.integer("port").alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("proxy", function (table) {
|
||||||
|
table.smallint("port").alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
12
db/knex_migrations/2025-05-09-0000-add-custom-url.js
Normal file
12
db/knex_migrations/2025-05-09-0000-add-custom-url.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Add column custom_url to monitor_group table
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor_group", function (table) {
|
||||||
|
table.text("custom_url", "text");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor_group", function (table) {
|
||||||
|
table.dropColumn("custom_url");
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2025-06-03-0000-add-ip-family.js
Normal file
11
db/knex_migrations/2025-06-03-0000-add-ip-family.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.boolean("ip_family").defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("ip_family");
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2025-06-11-0000-add-manual-monitor.js
Normal file
11
db/knex_migrations/2025-06-11-0000-add-manual-monitor.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("manual_status").defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("manual_status");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Add column last_start_date to maintenance table
|
||||||
|
exports.up = async function (knex) {
|
||||||
|
await knex.schema.alterTable("maintenance", function (table) {
|
||||||
|
table.datetime("last_start_date");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Perform migration for recurring-interval strategy
|
||||||
|
const recurringMaintenances = await knex("maintenance")
|
||||||
|
.where({
|
||||||
|
strategy: "recurring-interval",
|
||||||
|
cron: "* * * * *",
|
||||||
|
})
|
||||||
|
.select("id", "start_time");
|
||||||
|
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
|
const maintenanceUpdates = recurringMaintenances.map(async ({ start_time, id }) => {
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
|
const [hourStr, minuteStr] = start_time.split(":");
|
||||||
|
const hour = parseInt(hourStr, 10);
|
||||||
|
const minute = parseInt(minuteStr, 10);
|
||||||
|
|
||||||
|
const cron = `${minute} ${hour} * * *`;
|
||||||
|
|
||||||
|
await knex("maintenance").where({ id }).update({ cron });
|
||||||
|
});
|
||||||
|
await Promise.all(maintenanceUpdates);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("maintenance", function (table) {
|
||||||
|
table.dropColumn("last_start_date");
|
||||||
|
});
|
||||||
|
};
|
||||||
12
db/knex_migrations/2025-06-15-0001-manual-monitor-fix.js
Normal file
12
db/knex_migrations/2025-06-15-0001-manual-monitor-fix.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Fix: Change manual_status column type to smallint
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.smallint("manual_status").alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("manual_status").alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2025-06-24-0000-add-audience-to-oauth.js
Normal file
11
db/knex_migrations/2025-06-24-0000-add-audience-to-oauth.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("oauth_audience").nullable().defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("oauth_audience").alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
13
db/knex_migrations/2025-07-17-0000-mqtt-websocket-path.js
Normal file
13
db/knex_migrations/2025-07-17-0000-mqtt-websocket-path.js
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Add new column monitor.mqtt_websocket_path
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("mqtt_websocket_path", 255).nullable();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
// Drop column monitor.mqtt_websocket_path
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("mqtt_websocket_path");
|
||||||
|
});
|
||||||
|
};
|
||||||
23
db/knex_migrations/2025-09-02-0000-add-domain-expiry.js
Normal file
23
db/knex_migrations/2025-09-02-0000-add-domain-expiry.js
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("monitor", function (table) {
|
||||||
|
table.boolean("domain_expiry_notification").defaultTo(1);
|
||||||
|
})
|
||||||
|
.createTable("domain_expiry", (table) => {
|
||||||
|
table.increments("id");
|
||||||
|
table.datetime("last_check");
|
||||||
|
// Use VARCHAR(255) for MySQL/MariaDB compatibility with unique constraint
|
||||||
|
// Maximum domain name length is 253 characters (255 octets on the wire)
|
||||||
|
table.string("domain", 255).unique().notNullable();
|
||||||
|
table.datetime("expiry");
|
||||||
|
table.integer("last_expiry_notification_sent").defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("monitor", function (table) {
|
||||||
|
table.boolean("domain_expiry_notification").alter();
|
||||||
|
})
|
||||||
|
.dropTable("domain_expiry");
|
||||||
|
};
|
||||||
14
db/knex_migrations/2025-10-14-0000-add-ip-family-fix.js
Normal file
14
db/knex_migrations/2025-10-14-0000-add-ip-family-fix.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
// Fix ip_family, change to varchar instead of boolean
|
||||||
|
// possible values are "ipv4" and "ipv6"
|
||||||
|
table.string("ip_family", 4).defaultTo(null).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
// Rollback to boolean
|
||||||
|
table.boolean("ip_family").defaultTo(null).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
27
db/knex_migrations/2025-10-15-0000-stat-table-fix.js
Normal file
27
db/knex_migrations/2025-10-15-0000-stat-table-fix.js
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Fix for #4315. Logically, setting it to 0 ping may not be correct, but it is better than throwing errors
|
||||||
|
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("stat_daily", function (table) {
|
||||||
|
table.integer("ping").defaultTo(0).alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_hourly", function (table) {
|
||||||
|
table.integer("ping").defaultTo(0).alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_minutely", function (table) {
|
||||||
|
table.integer("ping").defaultTo(0).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("stat_daily", function (table) {
|
||||||
|
table.integer("ping").alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_hourly", function (table) {
|
||||||
|
table.integer("ping").alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_minutely", function (table) {
|
||||||
|
table.integer("ping").alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.boolean("save_response").notNullable().defaultTo(false);
|
||||||
|
table.boolean("save_error_response").notNullable().defaultTo(true);
|
||||||
|
table.integer("response_max_length").notNullable().defaultTo(1024); // Default 1KB
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("save_response");
|
||||||
|
table.dropColumn("save_error_response");
|
||||||
|
table.dropColumn("response_max_length");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("heartbeat", function (table) {
|
||||||
|
table.text("response").nullable().defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("heartbeat", function (table) {
|
||||||
|
table.dropColumn("response");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Add new column status_page.show_only_last_heartbeat
|
||||||
|
return knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.boolean("show_only_last_heartbeat").notNullable().defaultTo(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
// Drop column status_page.show_only_last_heartbeat
|
||||||
|
return knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.dropColumn("show_only_last_heartbeat");
|
||||||
|
});
|
||||||
|
};
|
||||||
56
db/knex_migrations/2025-10-29-0000-better-auth.js
Normal file
56
db/knex_migrations/2025-10-29-0000-better-auth.js
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* The schema from: https://www.better-auth.com/docs/concepts/database#core-schema
|
||||||
|
*/
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.createTable("better_auth_user", (t) => {
|
||||||
|
t.string("id").primary();
|
||||||
|
t.string("name").notNullable();
|
||||||
|
t.string("email").notNullable();
|
||||||
|
t.boolean("emailVerified").notNullable();
|
||||||
|
t.string("image");
|
||||||
|
t.timestamp("createdAt").notNullable();
|
||||||
|
t.timestamp("updatedAt").notNullable();
|
||||||
|
})
|
||||||
|
.createTable("better_auth_session", (t) => {
|
||||||
|
t.string("id").primary();
|
||||||
|
t.string("userId").notNullable().references("id").inTable("better_auth_user");
|
||||||
|
t.string("token").notNullable();
|
||||||
|
t.timestamp("expiresAt").notNullable();
|
||||||
|
t.string("ipAddress");
|
||||||
|
t.string("userAgent");
|
||||||
|
t.timestamp("createdAt").notNullable();
|
||||||
|
t.timestamp("updatedAt").notNullable();
|
||||||
|
})
|
||||||
|
.createTable("better_auth_account", (t) => {
|
||||||
|
t.string("id").primary();
|
||||||
|
t.string("userId").notNullable().references("id").inTable("better_auth_user");
|
||||||
|
t.string("accountId").notNullable();
|
||||||
|
t.string("providerId").notNullable();
|
||||||
|
t.string("accessToken");
|
||||||
|
t.string("refreshToken");
|
||||||
|
t.timestamp("accessTokenExpiresAt");
|
||||||
|
t.timestamp("refreshTokenExpiresAt");
|
||||||
|
t.string("scope");
|
||||||
|
t.string("idToken");
|
||||||
|
t.string("password");
|
||||||
|
t.timestamp("createdAt").notNullable();
|
||||||
|
t.timestamp("updatedAt").notNullable();
|
||||||
|
})
|
||||||
|
.createTable("better_auth_verification", (t) => {
|
||||||
|
t.string("id").primary();
|
||||||
|
t.string("identifier").notNullable();
|
||||||
|
t.string("value").notNullable();
|
||||||
|
t.timestamp("expiresAt").notNullable();
|
||||||
|
t.timestamp("createdAt").notNullable();
|
||||||
|
t.timestamp("updatedAt").notNullable();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.dropTableIfExists("better_auth_verification")
|
||||||
|
.dropTableIfExists("better_auth_account")
|
||||||
|
.dropTableIfExists("better_auth_session")
|
||||||
|
.dropTableIfExists("better_auth_user");
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
/**
|
||||||
|
* @param {import("knex").Knex} knex The Knex.js instance for database interaction.
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
exports.up = async (knex) => {
|
||||||
|
await knex.schema.alterTable("monitor", (table) => {
|
||||||
|
table.string("system_service_name");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import("knex").Knex} knex The Knex.js instance for database interaction.
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
exports.down = async (knex) => {
|
||||||
|
await knex.schema.alterTable("monitor", (table) => {
|
||||||
|
table.dropColumn("system_service_name");
|
||||||
|
});
|
||||||
|
};
|
||||||
17
db/knex_migrations/2025-12-17-0000-add-globalping-monitor.js
Normal file
17
db/knex_migrations/2025-12-17-0000-add-globalping-monitor.js
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Add new columns
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("subtype", 10).nullable();
|
||||||
|
table.string("location", 255).nullable();
|
||||||
|
table.string("protocol", 20).nullable();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
// Drop columns
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("subtype");
|
||||||
|
table.dropColumn("location");
|
||||||
|
table.dropColumn("protocol");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
exports.up = async function (knex) {
|
||||||
|
const isSQLite = knex.client.dialect === "sqlite3";
|
||||||
|
|
||||||
|
if (isSQLite) {
|
||||||
|
// For SQLite: Use partial indexes with WHERE important = 1
|
||||||
|
// Drop existing indexes using IF EXISTS
|
||||||
|
await knex.raw("DROP INDEX IF EXISTS monitor_important_time_index");
|
||||||
|
await knex.raw("DROP INDEX IF EXISTS heartbeat_important_index");
|
||||||
|
|
||||||
|
// Create partial indexes with predicate
|
||||||
|
await knex.schema.alterTable("heartbeat", function (table) {
|
||||||
|
table.index(["monitor_id", "time"], "monitor_important_time_index", {
|
||||||
|
predicate: knex.whereRaw("important = 1"),
|
||||||
|
});
|
||||||
|
table.index(["important"], "heartbeat_important_index", {
|
||||||
|
predicate: knex.whereRaw("important = 1"),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// For MariaDB/MySQL: No changes (partial indexes not supported)
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async function (knex) {
|
||||||
|
const isSQLite = knex.client.dialect === "sqlite3";
|
||||||
|
|
||||||
|
if (isSQLite) {
|
||||||
|
// Restore original indexes
|
||||||
|
await knex.raw("DROP INDEX IF EXISTS monitor_important_time_index");
|
||||||
|
await knex.raw("DROP INDEX IF EXISTS heartbeat_important_index");
|
||||||
|
|
||||||
|
await knex.schema.alterTable("heartbeat", function (table) {
|
||||||
|
table.index(["monitor_id", "important", "time"], "monitor_important_time_index");
|
||||||
|
table.index(["important"]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// For MariaDB/MySQL: No changes
|
||||||
|
};
|
||||||
30
db/knex_migrations/2025-12-29-0000-remove-line-notify.js
Normal file
30
db/knex_migrations/2025-12-29-0000-remove-line-notify.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
exports.up = async function (knex) {
|
||||||
|
const notifications = await knex("notification").select("id", "config");
|
||||||
|
const lineNotifyIDs = [];
|
||||||
|
|
||||||
|
for (const { id, config } of notifications) {
|
||||||
|
try {
|
||||||
|
const parsedConfig = JSON.parse(config || "{}");
|
||||||
|
const type = typeof parsedConfig.type === "string" ? parsedConfig.type.toLowerCase() : "";
|
||||||
|
|
||||||
|
if (type === "linenotify" || type === "line-notify") {
|
||||||
|
lineNotifyIDs.push(id);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Ignore invalid JSON blobs here; they are handled elsewhere in the app.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lineNotifyIDs.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await knex.transaction(async (trx) => {
|
||||||
|
await trx("monitor_notification").whereIn("notification_id", lineNotifyIDs).del();
|
||||||
|
await trx("notification").whereIn("id", lineNotifyIDs).del();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async function () {
|
||||||
|
// Removal of LINE Notify configs is not reversible.
|
||||||
|
};
|
||||||
11
db/knex_migrations/2025-12-31-2143-add-snmp-v3-username.js
Normal file
11
db/knex_migrations/2025-12-31-2143-add-snmp-v3-username.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = async function (knex) {
|
||||||
|
await knex.schema.alterTable("monitor", (table) => {
|
||||||
|
table.string("snmp_v3_username", 255);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async function (knex) {
|
||||||
|
await knex.schema.alterTable("monitor", (table) => {
|
||||||
|
table.dropColumn("snmp_v3_username");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Change dns_last_result column from VARCHAR(255) to TEXT to handle longer DNS TXT records
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.text("dns_last_result").alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("dns_last_result", 255).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
186
db/knex_migrations/2026-01-02-0713-gamedig-v4-to-v5.js
Normal file
186
db/knex_migrations/2026-01-02-0713-gamedig-v4-to-v5.js
Normal file
|
|
@ -0,0 +1,186 @@
|
||||||
|
// Migration to update monitor.game from GameDig v4 to v5 game IDs
|
||||||
|
// Reference: https://github.com/gamedig/node-gamedig/blob/master/MIGRATE_IDS.md
|
||||||
|
|
||||||
|
// Lookup table mapping v4 game IDs to v5 game IDs
|
||||||
|
const gameDig4to5IdMap = {
|
||||||
|
americasarmypg: "aapg",
|
||||||
|
"7d2d": "sdtd",
|
||||||
|
as: "actionsource",
|
||||||
|
ageofchivalry: "aoc",
|
||||||
|
arkse: "ase",
|
||||||
|
arcasimracing: "asr08",
|
||||||
|
arma: "aaa",
|
||||||
|
arma2oa: "a2oa",
|
||||||
|
armacwa: "acwa",
|
||||||
|
armar: "armaresistance",
|
||||||
|
armare: "armareforger",
|
||||||
|
armagetron: "armagetronadvanced",
|
||||||
|
bat1944: "battalion1944",
|
||||||
|
bf1942: "battlefield1942",
|
||||||
|
bfv: "battlefieldvietnam",
|
||||||
|
bf2: "battlefield2",
|
||||||
|
bf2142: "battlefield2142",
|
||||||
|
bfbc2: "bbc2",
|
||||||
|
bf3: "battlefield3",
|
||||||
|
bf4: "battlefield4",
|
||||||
|
bfh: "battlefieldhardline",
|
||||||
|
bd: "basedefense",
|
||||||
|
bs: "bladesymphony",
|
||||||
|
buildandshoot: "bas",
|
||||||
|
cod4: "cod4mw",
|
||||||
|
callofjuarez: "coj",
|
||||||
|
chivalry: "cmw",
|
||||||
|
commandos3: "c3db",
|
||||||
|
cacrenegade: "cacr",
|
||||||
|
contactjack: "contractjack",
|
||||||
|
cs15: "counterstrike15",
|
||||||
|
cs16: "counterstrike16",
|
||||||
|
cs2: "counterstrike2",
|
||||||
|
crossracing: "crce",
|
||||||
|
darkesthour: "dhe4445",
|
||||||
|
daysofwar: "dow",
|
||||||
|
deadlydozenpt: "ddpt",
|
||||||
|
dh2005: "deerhunter2005",
|
||||||
|
dinodday: "ddd",
|
||||||
|
dirttrackracing2: "dtr2",
|
||||||
|
dmc: "deathmatchclassic",
|
||||||
|
dnl: "dal",
|
||||||
|
drakan: "dootf",
|
||||||
|
dys: "dystopia",
|
||||||
|
em: "empiresmod",
|
||||||
|
empyrion: "egs",
|
||||||
|
f12002: "formulaone2002",
|
||||||
|
flashpointresistance: "ofr",
|
||||||
|
fivem: "gta5f",
|
||||||
|
forrest: "theforrest",
|
||||||
|
graw: "tcgraw",
|
||||||
|
graw2: "tcgraw2",
|
||||||
|
giantscitizenkabuto: "gck",
|
||||||
|
ges: "goldeneyesource",
|
||||||
|
gore: "gus",
|
||||||
|
hldm: "hld",
|
||||||
|
hldms: "hlds",
|
||||||
|
hlopfor: "hlof",
|
||||||
|
hl2dm: "hl2d",
|
||||||
|
hidden: "thehidden",
|
||||||
|
had2: "hiddendangerous2",
|
||||||
|
igi2: "i2cs",
|
||||||
|
il2: "il2sturmovik",
|
||||||
|
insurgencymic: "imic",
|
||||||
|
isle: "theisle",
|
||||||
|
jamesbondnightfire: "jb007n",
|
||||||
|
jc2mp: "jc2m",
|
||||||
|
jc3mp: "jc3m",
|
||||||
|
kingpin: "kloc",
|
||||||
|
kisspc: "kpctnc",
|
||||||
|
kspdmp: "kspd",
|
||||||
|
kzmod: "kreedzclimbing",
|
||||||
|
left4dead: "l4d",
|
||||||
|
left4dead2: "l4d2",
|
||||||
|
m2mp: "m2m",
|
||||||
|
mohsh: "mohaas",
|
||||||
|
mohbt: "mohaab",
|
||||||
|
mohab: "moha",
|
||||||
|
moh2010: "moh",
|
||||||
|
mohwf: "mohw",
|
||||||
|
minecraftbe: "mbe",
|
||||||
|
mtavc: "gtavcmta",
|
||||||
|
mtasa: "gtasamta",
|
||||||
|
ns: "naturalselection",
|
||||||
|
ns2: "naturalselection2",
|
||||||
|
nwn: "neverwinternights",
|
||||||
|
nwn2: "neverwinternights2",
|
||||||
|
nolf: "tonolf",
|
||||||
|
nolf2: "nolf2asihw",
|
||||||
|
pvkii: "pvak2",
|
||||||
|
ps: "postscriptum",
|
||||||
|
primalcarnage: "pce",
|
||||||
|
pc: "projectcars",
|
||||||
|
pc2: "projectcars2",
|
||||||
|
prbf2: "prb2",
|
||||||
|
przomboid: "projectzomboid",
|
||||||
|
quake1: "quake",
|
||||||
|
quake3: "q3a",
|
||||||
|
ragdollkungfu: "rdkf",
|
||||||
|
r6: "rainbowsix",
|
||||||
|
r6roguespear: "rs2rs",
|
||||||
|
r6ravenshield: "rs3rs",
|
||||||
|
redorchestraost: "roo4145",
|
||||||
|
redm: "rdr2r",
|
||||||
|
riseofnations: "ron",
|
||||||
|
rs2: "rs2v",
|
||||||
|
samp: "gtasam",
|
||||||
|
saomp: "gtasao",
|
||||||
|
savage2: "s2ats",
|
||||||
|
ss: "serioussam",
|
||||||
|
ss2: "serioussam2",
|
||||||
|
ship: "theship",
|
||||||
|
sinep: "sinepisodes",
|
||||||
|
sonsoftheforest: "sotf",
|
||||||
|
swbf: "swb",
|
||||||
|
swbf2: "swb2",
|
||||||
|
swjk: "swjkja",
|
||||||
|
swjk2: "swjk2jo",
|
||||||
|
takeonhelicopters: "toh",
|
||||||
|
tf2: "teamfortress2",
|
||||||
|
terraria: "terrariatshock",
|
||||||
|
tribes1: "t1s",
|
||||||
|
ut: "unrealtournament",
|
||||||
|
ut2003: "unrealtournament2003",
|
||||||
|
ut2004: "unrealtournament2004",
|
||||||
|
ut3: "unrealtournament3",
|
||||||
|
v8supercar: "v8sc",
|
||||||
|
vcmp: "vcm",
|
||||||
|
vs: "vampireslayer",
|
||||||
|
wheeloftime: "wot",
|
||||||
|
wolfenstein2009: "wolfenstein",
|
||||||
|
wolfensteinet: "wet",
|
||||||
|
wurm: "wurmunlimited",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrate game IDs from v4 to v5
|
||||||
|
* @param {import("knex").Knex} knex - Knex instance
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
exports.up = async function (knex) {
|
||||||
|
await knex.transaction(async (trx) => {
|
||||||
|
// Get all monitors that use the gamedig type
|
||||||
|
const monitors = await trx("monitor").select("id", "game").where("type", "gamedig").whereNotNull("game");
|
||||||
|
|
||||||
|
// Update each monitor with the new game ID if it needs migration
|
||||||
|
for (const monitor of monitors) {
|
||||||
|
const oldGameId = monitor.game;
|
||||||
|
const newGameId = gameDig4to5IdMap[oldGameId];
|
||||||
|
|
||||||
|
if (newGameId) {
|
||||||
|
await trx("monitor").where("id", monitor.id).update({ game: newGameId });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Revert game IDs from v5 back to v4
|
||||||
|
* @param {import("knex").Knex} knex - Knex instance
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
exports.down = async function (knex) {
|
||||||
|
// Create reverse mapping from the same LUT
|
||||||
|
const gameDig5to4IdMap = Object.fromEntries(Object.entries(gameDig4to5IdMap).map(([v4, v5]) => [v5, v4]));
|
||||||
|
|
||||||
|
await knex.transaction(async (trx) => {
|
||||||
|
// Get all monitors that use the gamedig type
|
||||||
|
const monitors = await trx("monitor").select("id", "game").where("type", "gamedig").whereNotNull("game");
|
||||||
|
|
||||||
|
// Revert each monitor back to the old game ID if it was migrated
|
||||||
|
for (const monitor of monitors) {
|
||||||
|
const newGameId = monitor.game;
|
||||||
|
const oldGameId = gameDig5to4IdMap[newGameId];
|
||||||
|
|
||||||
|
if (oldGameId) {
|
||||||
|
await trx("monitor").where("id", monitor.id).update({ game: oldGameId });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2026-01-05-0000-add-rss-title.js
Normal file
11
db/knex_migrations/2026-01-05-0000-add-rss-title.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = async function (knex) {
|
||||||
|
await knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.string("rss_title", 255);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.dropColumn("rss_title");
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2026-01-05-0000-add-tls-monitor.js
Normal file
11
db/knex_migrations/2026-01-05-0000-add-tls-monitor.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.string("expected_tls_alert", 50).defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("expected_tls_alert");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Ensure domain column is VARCHAR(255) across all database types.
|
||||||
|
// This migration ensures MySQL, SQLite, and MariaDB have consistent column type,
|
||||||
|
// even if a user installed 2.1.0-beta.0 or 2.1.0-beta.1 which had TEXT type for this column.
|
||||||
|
// Maximum domain name length is 253 characters (255 octets on the wire).
|
||||||
|
// Note: The unique constraint is already present from the original migration.
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("domain_expiry", function (table) {
|
||||||
|
table.string("domain", 255).notNullable().alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
// No rollback needed - keeping VARCHAR(255) is the correct state
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("heartbeat", function (table) {
|
||||||
|
table.bigInteger("ping").alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_minutely", function (table) {
|
||||||
|
table.float("ping", 20, 2).notNullable().alter();
|
||||||
|
table.float("ping_min", 20, 2).notNullable().defaultTo(0).alter();
|
||||||
|
table.float("ping_max", 20, 2).notNullable().defaultTo(0).alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_daily", function (table) {
|
||||||
|
table.float("ping", 20, 2).notNullable().alter();
|
||||||
|
table.float("ping_min", 20, 2).notNullable().defaultTo(0).alter();
|
||||||
|
table.float("ping_max", 20, 2).notNullable().defaultTo(0).alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_hourly", function (table) {
|
||||||
|
table.float("ping", 20, 2).notNullable().alter();
|
||||||
|
table.float("ping_min", 20, 2).notNullable().defaultTo(0).alter();
|
||||||
|
table.float("ping_max", 20, 2).notNullable().defaultTo(0).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("heartbeat", function (table) {
|
||||||
|
table.integer("ping").alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_minutely", function (table) {
|
||||||
|
table.float("ping").notNullable().alter();
|
||||||
|
table.float("ping_min").notNullable().defaultTo(0).alter();
|
||||||
|
table.float("ping_max").notNullable().defaultTo(0).alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_daily", function (table) {
|
||||||
|
table.float("ping").notNullable().alter();
|
||||||
|
table.float("ping_min").notNullable().defaultTo(0).alter();
|
||||||
|
table.float("ping_max").notNullable().defaultTo(0).alter();
|
||||||
|
})
|
||||||
|
.alterTable("stat_hourly", function (table) {
|
||||||
|
table.float("ping").notNullable().alter();
|
||||||
|
table.float("ping_min").notNullable().defaultTo(0).alter();
|
||||||
|
table.float("ping_max").notNullable().defaultTo(0).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Add new column to table monitor for json-query retry behavior
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.boolean("retry_only_on_status_code_failure").defaultTo(false).notNullable();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("retry_only_on_status_code_failure");
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2026-01-16-0000-add-screenshot-delay.js
Normal file
11
db/knex_migrations/2026-01-16-0000-add-screenshot-delay.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.integer("screenshot_delay").notNullable().unsigned().defaultTo(0);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("screenshot_delay");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
const { parse: parseTld } = require("tldts");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO:
|
||||||
|
* This migration file is scary, because the json file is dynamically updated.
|
||||||
|
* Problem 1: Migration files should ideally be stateless.
|
||||||
|
* Problem 2: This migration only runs once, what happens if rdp-dns.json is updated after this migration has run?
|
||||||
|
* Have to investigate later.
|
||||||
|
*/
|
||||||
|
const rdapDnsData = require("../../extra/rdap-dns.json");
|
||||||
|
|
||||||
|
const TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD = {
|
||||||
|
http: "url",
|
||||||
|
keyword: "url",
|
||||||
|
"json-query": "url",
|
||||||
|
"real-browser": "url",
|
||||||
|
"websocket-upgrade": "url",
|
||||||
|
port: "hostname",
|
||||||
|
ping: "hostname",
|
||||||
|
"grpc-keyword": "grpc_url",
|
||||||
|
dns: "hostname",
|
||||||
|
smtp: "hostname",
|
||||||
|
snmp: "hostname",
|
||||||
|
gamedig: "hostname",
|
||||||
|
steam: "hostname",
|
||||||
|
mqtt: "hostname",
|
||||||
|
radius: "hostname",
|
||||||
|
"tailscale-ping": "hostname",
|
||||||
|
"sip-options": "hostname",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build set of root TLDs that have RDAP support
|
||||||
|
* @returns {Set<string>} Set of supported root TLDs
|
||||||
|
*/
|
||||||
|
function getSupportedTlds() {
|
||||||
|
const supported = new Set();
|
||||||
|
const services = rdapDnsData["services"] ?? [];
|
||||||
|
for (const [tlds] of services) {
|
||||||
|
for (const tld of tlds) {
|
||||||
|
supported.add(tld);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return supported;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a target URL/hostname has RDAP support
|
||||||
|
* @param {string} target URL or hostname
|
||||||
|
* @param {Set<string>} supportedTlds Set of supported root TLDs
|
||||||
|
* @returns {boolean} Whether the target's TLD has RDAP support
|
||||||
|
*/
|
||||||
|
function hasRdapSupport(target, supportedTlds) {
|
||||||
|
if (!target || typeof target !== "string") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const tld = parseTld(target);
|
||||||
|
if (!tld.publicSuffix || !tld.isIcann) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const rootTld = tld.publicSuffix.split(".").pop();
|
||||||
|
return supportedTlds.has(rootTld);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.up = async function (knex) {
|
||||||
|
const supportedTlds = getSupportedTlds();
|
||||||
|
|
||||||
|
const monitors = await knex("monitor")
|
||||||
|
.where("domain_expiry_notification", 1)
|
||||||
|
.select("id", "type", "url", "hostname", "grpc_url");
|
||||||
|
|
||||||
|
const idsToDisable = [];
|
||||||
|
for (const monitor of monitors) {
|
||||||
|
const targetField = TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD[monitor.type];
|
||||||
|
if (!targetField || !hasRdapSupport(monitor[targetField], supportedTlds)) {
|
||||||
|
idsToDisable.push(monitor.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idsToDisable.length > 0) {
|
||||||
|
await knex("monitor").whereIn("id", idsToDisable).update("domain_expiry_notification", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
await knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.boolean("domain_expiry_notification").defaultTo(0).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async function (knex) {
|
||||||
|
await knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.boolean("domain_expiry_notification").defaultTo(1).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
15
db/knex_migrations/2026-03-27-0000-add-ntp-monitor.js
Normal file
15
db/knex_migrations/2026-03-27-0000-add-ntp-monitor.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.integer("ntp_stratum_threshold").defaultTo(5);
|
||||||
|
table.integer("ntp_time_offset_threshold").defaultTo(1000);
|
||||||
|
table.integer("ntp_root_dispersion_threshold").defaultTo(500);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("ntp_stratum_threshold");
|
||||||
|
table.dropColumn("ntp_time_offset_threshold");
|
||||||
|
table.dropColumn("ntp_root_dispersion_threshold");
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2026-05-20-0000-add-bearer-token.js
Normal file
11
db/knex_migrations/2026-05-20-0000-add-bearer-token.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.text("bearer_token").defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("bearer_token");
|
||||||
|
});
|
||||||
|
};
|
||||||
11
db/knex_migrations/2026-05-25-0000-add-gamedig-token.js
Normal file
11
db/knex_migrations/2026-05-25-0000-add-gamedig-token.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.text("gamedig_token").defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("gamedig_token");
|
||||||
|
});
|
||||||
|
};
|
||||||
16
db/knex_migrations/2026-05-26-0000-better-auth-username.js
Normal file
16
db/knex_migrations/2026-05-26-0000-better-auth-username.js
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* The schema from: https://better-auth.com/docs/plugins/username#schema
|
||||||
|
*/
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.table("better_auth_user", (t) => {
|
||||||
|
t.string("username").unique();
|
||||||
|
t.string("displayUsername");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.table("better_auth_user", (t) => {
|
||||||
|
t.dropColumn("username");
|
||||||
|
t.dropColumn("displayUsername");
|
||||||
|
});
|
||||||
|
};
|
||||||
28
db/knex_migrations/2026-05-26-0010-better-auth-admin.js
Normal file
28
db/knex_migrations/2026-05-26-0010-better-auth-admin.js
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* The schema from: https://better-auth.com/docs/plugins/admin#schema
|
||||||
|
*/
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.table("better_auth_user", function (table) {
|
||||||
|
table.text("role");
|
||||||
|
table.boolean("banned");
|
||||||
|
table.text("banReason");
|
||||||
|
table.timestamp("banExpires");
|
||||||
|
})
|
||||||
|
.table("better_auth_session", function (table) {
|
||||||
|
table.text("impersonatedBy");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.table("better_auth_user", function (table) {
|
||||||
|
table.dropColumn("role");
|
||||||
|
table.dropColumn("banned");
|
||||||
|
table.dropColumn("banReason");
|
||||||
|
table.dropColumn("banExpires");
|
||||||
|
})
|
||||||
|
.table("better_auth_session", function (table) {
|
||||||
|
table.dropColumn("impersonatedBy");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
const tables = [
|
||||||
|
{
|
||||||
|
name: "docker_host",
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "proxy",
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "monitor",
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "maintenance",
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "notification",
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "api_key",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "remote_browser",
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
exports.up = async function (knex) {
|
||||||
|
for (const table of tables) {
|
||||||
|
try {
|
||||||
|
await knex.schema.alterTable(table.name, (t) => {
|
||||||
|
t.dropForeign("user_id");
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
// Not sure why it only happens on Ubuntu 22.04 + Node.js 26
|
||||||
|
// Error: Can't DROP 'docker_host_user_id_foreign'; check that column/key exists
|
||||||
|
console.error(`Error dropping foreign key for table ${table.name}:`, error);
|
||||||
|
|
||||||
|
const columns = await knex(table.name).columnInfo();
|
||||||
|
console.error(`Schema for ${table.name}:`, JSON.stringify(columns, null, 2));
|
||||||
|
|
||||||
|
// Try to ignore it, because the foreign key not existing, we can just drop user_id
|
||||||
|
// throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
await knex.schema.alterTable(table.name, (t) => {
|
||||||
|
t.dropColumn("user_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.schema.alterTable(table.name, (t) => {
|
||||||
|
t.string("user_id", 255).nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.schema.alterTable(table.name, (t) => {
|
||||||
|
t.foreign("user_id")
|
||||||
|
.references("id")
|
||||||
|
.inTable("better_auth_user")
|
||||||
|
.onDelete(table.onDelete)
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async function (knex) {
|
||||||
|
for (const table of tables) {
|
||||||
|
await knex.schema.alterTable(table.name, (t) => {
|
||||||
|
t.dropForeign("user_id");
|
||||||
|
t.dropColumn("user_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.schema.alterTable(table.name, (t) => {
|
||||||
|
t.integer("user_id").unsigned().nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.schema.alterTable(table.name, (t) => {
|
||||||
|
t.foreign("user_id").references("id").inTable("user").onDelete(table.onDelete).onUpdate("CASCADE");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
27
db/knex_migrations/2026-06-08-0000-better-auth-2fa.js
Normal file
27
db/knex_migrations/2026-06-08-0000-better-auth-2fa.js
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* The schema from: https://better-auth.com/docs/plugins/2fa#schema
|
||||||
|
*/
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.createTable("better_auth_twoFactor", (t) => {
|
||||||
|
t.string("id").primary();
|
||||||
|
t.string("secret").notNullable();
|
||||||
|
t.string("backupCodes").notNullable();
|
||||||
|
t.boolean("verified").notNullable();
|
||||||
|
t.string("userId")
|
||||||
|
.notNullable()
|
||||||
|
.references("id")
|
||||||
|
.inTable("better_auth_user")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
})
|
||||||
|
.table("better_auth_user", (t) => {
|
||||||
|
t.boolean("twoFactorEnabled");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.dropTableIfExists("better_auth_twoFactor").table("better_auth_user", (t) => {
|
||||||
|
t.dropColumn("twoFactorEnabled");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Intentionally left blank - no operation
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async function (knex) {
|
||||||
|
// Intentionally left blank - no operation
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
const oldValues = ["google", "umami", "plausible", "matomo", "rybbit"];
|
||||||
|
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.string("analytics_type").nullable().defaultTo(null).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async function (knex) {
|
||||||
|
await knex("status_page")
|
||||||
|
.whereNotNull("analytics_type")
|
||||||
|
.whereNotIn("analytics_type", oldValues)
|
||||||
|
.update({ analytics_type: null });
|
||||||
|
|
||||||
|
return knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.enu("analytics_type", oldValues).nullable().defaultTo(null).alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
40
db/knex_migrations/2026-06-29-0000-better-auth-api-key.js
Normal file
40
db/knex_migrations/2026-06-29-0000-better-auth-api-key.js
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* The api key schema from: https://www.better-auth.com/docs/plugins/api-key/reference#schema
|
||||||
|
* Plugin: @better-auth/api-key (modelName: better_auth_apikey)
|
||||||
|
*/
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.createTable("better_auth_apikey", (t) => {
|
||||||
|
t.string("id").primary();
|
||||||
|
t.string("configId").notNullable().defaultTo("default").index();
|
||||||
|
t.string("name");
|
||||||
|
t.string("start");
|
||||||
|
t.string("prefix");
|
||||||
|
t.string("key").notNullable().index();
|
||||||
|
t.string("referenceId")
|
||||||
|
.notNullable()
|
||||||
|
.index()
|
||||||
|
.references("id")
|
||||||
|
.inTable("better_auth_user")
|
||||||
|
.onDelete("CASCADE")
|
||||||
|
.onUpdate("CASCADE");
|
||||||
|
t.integer("refillInterval");
|
||||||
|
t.integer("refillAmount");
|
||||||
|
t.timestamp("lastRefillAt");
|
||||||
|
t.boolean("enabled").defaultTo(true);
|
||||||
|
t.boolean("rateLimitEnabled").defaultTo(true);
|
||||||
|
t.bigInteger("rateLimitTimeWindow");
|
||||||
|
t.integer("rateLimitMax");
|
||||||
|
t.integer("requestCount").defaultTo(0);
|
||||||
|
t.integer("remaining");
|
||||||
|
t.timestamp("lastRequest");
|
||||||
|
t.timestamp("expiresAt");
|
||||||
|
t.timestamp("createdAt").notNullable();
|
||||||
|
t.timestamp("updatedAt").notNullable();
|
||||||
|
t.text("permissions");
|
||||||
|
t.text("metadata");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.dropTableIfExists("better_auth_apikey");
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.alterTable("stat_daily", function (table) {
|
||||||
|
table.integer("up").unsigned().notNullable().alter();
|
||||||
|
table.integer("down").unsigned().notNullable().alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("stat_daily", function (table) {
|
||||||
|
table.smallint("up").notNullable().alter();
|
||||||
|
table.smallint("down").notNullable().alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
21
db/knex_migrations/2026-08-07-0000-add-sftp-monitor.js
Normal file
21
db/knex_migrations/2026-08-07-0000-add-sftp-monitor.js
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
exports.up = async (knex) => {
|
||||||
|
await knex.schema.alterTable("monitor", (table) => {
|
||||||
|
table.string("ssh_username");
|
||||||
|
table.string("ssh_password");
|
||||||
|
table.string("sftp_path");
|
||||||
|
table.text("ssh_private_key");
|
||||||
|
table.string("ssh_passphrase");
|
||||||
|
table.string("ssh_auth_method").defaultTo("password");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async (knex) => {
|
||||||
|
await knex.schema.alterTable("monitor", (table) => {
|
||||||
|
table.dropColumn("ssh_username");
|
||||||
|
table.dropColumn("ssh_password");
|
||||||
|
table.dropColumn("sftp_path");
|
||||||
|
table.dropColumn("ssh_private_key");
|
||||||
|
table.dropColumn("ssh_passphrase");
|
||||||
|
table.dropColumn("ssh_auth_method");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
// Fix #7727, force recreate analytics_type the column on SQLite to remove the enum check
|
||||||
|
// Because alter to string won't remove the enum the check (so stupid....)
|
||||||
|
|
||||||
|
exports.up = async function (knex) {
|
||||||
|
if (knex.client.dialect === "sqlite3") {
|
||||||
|
// Save all analytics_type to memory
|
||||||
|
const rows = await knex("status_page").select("id", "analytics_type");
|
||||||
|
|
||||||
|
await knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.dropColumn("analytics_type");
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.string("analytics_type").nullable().defaultTo(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const row of rows) {
|
||||||
|
if (row.analytics_type !== null) {
|
||||||
|
await knex("status_page").where({ id: row.id }).update({ analytics_type: row.analytics_type });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async function (knex) {
|
||||||
|
if (knex.client.dialect === "sqlite3") {
|
||||||
|
const rows = await knex("status_page").select("id", "analytics_type");
|
||||||
|
|
||||||
|
await knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table.dropColumn("analytics_type");
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.schema.alterTable("status_page", function (table) {
|
||||||
|
table
|
||||||
|
.enu("analytics_type", ["google", "umami", "plausible", "matomo", "rybbit"])
|
||||||
|
.nullable()
|
||||||
|
.defaultTo(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const row of rows) {
|
||||||
|
if (row.analytics_type !== null) {
|
||||||
|
await knex("status_page").where({ id: row.id }).update({ analytics_type: row.analytics_type });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
51
db/knex_migrations/README.md
Normal file
51
db/knex_migrations/README.md
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
# Info
|
||||||
|
|
||||||
|
https://knexjs.org/guide/migrations.html#knexfile-in-other-languages
|
||||||
|
|
||||||
|
## Basic rules
|
||||||
|
|
||||||
|
- All tables must have a primary key named `id`
|
||||||
|
- Filename format: `YYYY-MM-DD-HHMM-patch-name.js`
|
||||||
|
- Avoid native SQL syntax, use knex methods, because Uptime Kuma supports SQLite and MariaDB.
|
||||||
|
|
||||||
|
## Template
|
||||||
|
|
||||||
|
```js
|
||||||
|
exports.up = function (knex) {};
|
||||||
|
|
||||||
|
exports.down = function (knex) {};
|
||||||
|
|
||||||
|
// exports.config = { transaction: false };
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
Filename: 2023-06-30-1348-create-user-and-product.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.createTable("user", function (table) {
|
||||||
|
table.increments("id");
|
||||||
|
table.string("first_name", 255).notNullable();
|
||||||
|
table.string("last_name", 255).notNullable();
|
||||||
|
})
|
||||||
|
.createTable("product", function (table) {
|
||||||
|
table.increments("id");
|
||||||
|
table.decimal("price").notNullable();
|
||||||
|
table.string("name", 1000).notNullable();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
knex("products").insert([
|
||||||
|
{ price: 10, name: "Apple" },
|
||||||
|
{ price: 20, name: "Orange" },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.dropTable("product").dropTable("user");
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
https://knexjs.org/guide/migrations.html#transactions-in-migrations
|
||||||
3
db/old_migrations/README.md
Normal file
3
db/old_migrations/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Don't create a new migration file here
|
||||||
|
|
||||||
|
Please go to ./db/knex_migrations/README.md
|
||||||
7
db/old_migrations/patch-2fa-invalidate-used-token.sql
Normal file
7
db/old_migrations/patch-2fa-invalidate-used-token.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE user
|
||||||
|
ADD twofa_last_token VARCHAR(6);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
10
db/old_migrations/patch-2fa.sql
Normal file
10
db/old_migrations/patch-2fa.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE user
|
||||||
|
ADD twofa_secret VARCHAR(64);
|
||||||
|
|
||||||
|
ALTER TABLE user
|
||||||
|
ADD twofa_status BOOLEAN default 0 NOT NULL;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE status_page
|
||||||
|
ADD show_certificate_expiry BOOLEAN default 0 NOT NULL;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor_group
|
||||||
|
ADD send_url BOOLEAN DEFAULT 0 NOT NULL;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
7
db/old_migrations/patch-add-description-monitor.sql
Normal file
7
db/old_migrations/patch-add-description-monitor.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD description TEXT default null;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
18
db/old_migrations/patch-add-docker-columns.sql
Normal file
18
db/old_migrations/patch-add-docker-columns.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
CREATE TABLE docker_host (
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INT NOT NULL,
|
||||||
|
docker_daemon VARCHAR(255),
|
||||||
|
docker_type VARCHAR(255),
|
||||||
|
name VARCHAR(255)
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD docker_host INTEGER REFERENCES docker_host(id);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD docker_container VARCHAR(255);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
7
db/old_migrations/patch-add-gamedig-given-port.sql
Normal file
7
db/old_migrations/patch-add-gamedig-given-port.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD gamedig_given_port_only BOOLEAN default 1 not null;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
7
db/old_migrations/patch-add-gamedig-monitor.sql
Normal file
7
db/old_migrations/patch-add-gamedig-monitor.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD game VARCHAR(255);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE status_page
|
||||||
|
ADD google_analytics_tag_id VARCHAR;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
7
db/old_migrations/patch-add-invert-keyword.sql
Normal file
7
db/old_migrations/patch-add-invert-keyword.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD invert_keyword BOOLEAN default 0 not null;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
18
db/old_migrations/patch-add-other-auth.sql
Normal file
18
db/old_migrations/patch-add-other-auth.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD auth_method VARCHAR(250);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD auth_domain TEXT;
|
||||||
|
ALTER TABLE monitor
|
||||||
|
|
||||||
|
ADD auth_workstation TEXT;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
UPDATE monitor
|
||||||
|
SET auth_method = 'basic'
|
||||||
|
WHERE basic_auth_user is not null;
|
||||||
|
COMMIT;
|
||||||
7
db/old_migrations/patch-add-parent-monitor.sql
Normal file
7
db/old_migrations/patch-add-parent-monitor.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD parent INTEGER REFERENCES [monitor] ([id]) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
19
db/old_migrations/patch-add-radius-monitor.sql
Normal file
19
db/old_migrations/patch-add-radius-monitor.sql
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD radius_username VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD radius_password VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD radius_calling_station_id VARCHAR(50);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD radius_called_station_id VARCHAR(50);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD radius_secret VARCHAR(255);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
7
db/old_migrations/patch-add-retry-interval-monitor.sql
Normal file
7
db/old_migrations/patch-add-retry-interval-monitor.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD retry_interval INTEGER default 0 not null;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
10
db/old_migrations/patch-add-sqlserver-monitor.sql
Normal file
10
db/old_migrations/patch-add-sqlserver-monitor.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD database_connection_string VARCHAR(2000);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD database_query TEXT;
|
||||||
|
|
||||||
|
|
||||||
|
COMMIT
|
||||||
7
db/old_migrations/patch-add-timeout-monitor.sql
Normal file
7
db/old_migrations/patch-add-timeout-monitor.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD timeout DOUBLE default 0 not null;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
10
db/old_migrations/patch-added-json-query.sql
Normal file
10
db/old_migrations/patch-added-json-query.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD json_path TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD expected_value VARCHAR(255);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
22
db/old_migrations/patch-added-kafka-producer.sql
Normal file
22
db/old_migrations/patch-added-kafka-producer.sql
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_topic VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_brokers TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_ssl INTEGER;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_allow_auto_topic_creation VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_sasl_options TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD kafka_producer_message TEXT;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
16
db/old_migrations/patch-added-mqtt-monitor.sql
Normal file
16
db/old_migrations/patch-added-mqtt-monitor.sql
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD mqtt_topic TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD mqtt_success_message VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD mqtt_username VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD mqtt_password VARCHAR(255);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
15
db/old_migrations/patch-api-key-table.sql
Normal file
15
db/old_migrations/patch-api-key-table.sql
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
CREATE TABLE [api_key] (
|
||||||
|
[id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
[key] VARCHAR(255) NOT NULL,
|
||||||
|
[name] VARCHAR(255) NOT NULL,
|
||||||
|
[user_id] INTEGER NOT NULL,
|
||||||
|
[created_date] DATETIME DEFAULT (DATETIME('now')) NOT NULL,
|
||||||
|
[active] BOOLEAN DEFAULT 1 NOT NULL,
|
||||||
|
[expires] DATETIME DEFAULT NULL,
|
||||||
|
CONSTRAINT FK_user FOREIGN KEY ([user_id]) REFERENCES [user]([id]) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
34
db/old_migrations/patch-fix-kafka-producer-booleans.sql
Normal file
34
db/old_migrations/patch-fix-kafka-producer-booleans.sql
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
-- Rename COLUMNs to another one (suffixed by `_old`)
|
||||||
|
ALTER TABLE monitor
|
||||||
|
RENAME COLUMN kafka_producer_ssl TO kafka_producer_ssl_old;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
RENAME COLUMN kafka_producer_allow_auto_topic_creation TO kafka_producer_allow_auto_topic_creation_old;
|
||||||
|
|
||||||
|
-- Add correct COLUMNs
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD COLUMN kafka_producer_ssl BOOLEAN default 0 NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD COLUMN kafka_producer_allow_auto_topic_creation BOOLEAN default 0 NOT NULL;
|
||||||
|
|
||||||
|
-- These SQL is still not fully safe. See https://github.com/louislam/uptime-kuma/issues/4039.
|
||||||
|
|
||||||
|
-- Set bring old values from `_old` COLUMNs to correct ones
|
||||||
|
-- UPDATE monitor SET kafka_producer_allow_auto_topic_creation = monitor.kafka_producer_allow_auto_topic_creation_old
|
||||||
|
-- WHERE monitor.kafka_producer_allow_auto_topic_creation_old IS NOT NULL;
|
||||||
|
|
||||||
|
-- UPDATE monitor SET kafka_producer_ssl = monitor.kafka_producer_ssl_old
|
||||||
|
-- WHERE monitor.kafka_producer_ssl_old IS NOT NULL;
|
||||||
|
|
||||||
|
-- Remove old COLUMNs
|
||||||
|
ALTER TABLE monitor
|
||||||
|
DROP COLUMN kafka_producer_allow_auto_topic_creation_old;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
DROP COLUMN kafka_producer_ssl_old;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
30
db/old_migrations/patch-group-table.sql
Normal file
30
db/old_migrations/patch-group-table.sql
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
create table `group`
|
||||||
|
(
|
||||||
|
id INTEGER not null
|
||||||
|
constraint group_pk
|
||||||
|
primary key autoincrement,
|
||||||
|
name VARCHAR(255) not null,
|
||||||
|
created_date DATETIME default (DATETIME('now')) not null,
|
||||||
|
public BOOLEAN default 0 not null,
|
||||||
|
active BOOLEAN default 1 not null,
|
||||||
|
weight BOOLEAN NOT NULL DEFAULT 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE [monitor_group]
|
||||||
|
(
|
||||||
|
[id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
|
[monitor_id] INTEGER NOT NULL REFERENCES [monitor] ([id]) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
[group_id] INTEGER NOT NULL REFERENCES [group] ([id]) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
weight BOOLEAN NOT NULL DEFAULT 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX [fk]
|
||||||
|
ON [monitor_group] (
|
||||||
|
[monitor_id],
|
||||||
|
[group_id]);
|
||||||
|
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
25
db/old_migrations/patch-grpc-monitor.sql
Normal file
25
db/old_migrations/patch-grpc-monitor.sql
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD grpc_url VARCHAR(255) default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD grpc_protobuf TEXT default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD grpc_body TEXT default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD grpc_metadata TEXT default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD grpc_method VARCHAR(255) default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD grpc_service_name VARCHAR(255) default null;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD grpc_enable_tls BOOLEAN default 0 not null;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue