Commit Graph

29 Commits

Author SHA1 Message Date
饺子w (Yumechi) 496c166981
chore: Migrate github.com/jinzhu/gorm to gorm.io/gorm (#863)
* chore: Migrate github.com/jinzhu/gorm to gorm.io/gorm

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* chore: drop singleton connection limit on sqlite3 backend

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* enhance: database logging

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* Revert "chore: drop singleton connection limit on sqlite3 backend"

This reverts commit b494a3bd1f2e18dc9b5e57bbb87e755a6247452f.

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* typo

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* rename unique_index -> uniqueIndex

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* drop uniqueIndex on primary key

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* migrate fully to new gorm tag format

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* specify unique index name

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* remove pluginConf duplicate index

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* disable auto migrate FK

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

---------

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
2025-10-29 22:23:10 +00:00
Luc Didry afe2a730dc
fix: consistent app ordering (#802)
See #358
2025-05-29 19:17:08 +00:00
eternal-flame-AD 7bf80ee6f1 Add last used to client & application 2023-08-06 12:30:22 +02:00
Jannis Mattheis 59b2ed17a6 Update linter 2022-05-29 19:45:45 +02:00
Jannis Mattheis 3454dcd602 Use golangci-lint 2020-11-01 10:47:02 +01:00
Jannis Mattheis 92a468bf74 Fix packets.go:36: unexpected EOF
Mysql has a setting called wait_timeout, which defines the duration
after which a connection may not be used anymore. Gotify doesn't
apply this, and expects the connection to work without timeout.

The fix is to set SetConnMaxLifetime, this however, isn't the
exact counterpart for wait_timeout on mysql. wait_timeout is
relative to the last use of the connection. The go setting
uses the creation of the connection as base.

Example error output:
```
[mysql] 2020/05/31 17:53:02 packets.go:36: unexpected EOF
[GIN] 2020/05/31 - 17:53:02 | 500 |     247.062µs |        10.2.2.1 | GET      "/application"
Error #01: an error occured while authenticating user

(/proj/database/client.go:24)
[2020-05-31 17:53:02]  invalid connection
```
2020-06-01 19:16:12 +02:00
Jannis Mattheis 7b90b8a8f5 Use v2 in package path 2020-05-08 10:43:17 +02:00
Jannis Mattheis 81c4a73df3 Add health api 2019-08-16 09:28:57 +02:00
饺子w 11e0a4b0df Fix blob inconsistency in mysql (#196)
By default gorm uses the type `varbinary(255)` for []byte in database models. 255 characters isn't enough for a plugin config therefore we use longblob instead.
2019-06-11 18:16:25 +02:00
饺子w 67493c643e Return 500 server error on database failures (#191) 2019-05-25 08:37:24 +02:00
GianOrtiz e32359ed15 Add update client api and dialog (#164) 2019-03-16 11:18:51 +01:00
饺子w 2fa395cb84 Prevent removing last admin (#130) 2019-02-26 18:46:42 +01:00
eternal-flame-AD e5b24f4c92 Add plugin feature
Fixed database migration
Added a plugin system based on the go plugin package
2019-02-09 12:52:01 +01:00
Eugene Gavrilov 4a6863eda2 [#69] add end-point for update application name and description 2018-11-23 21:39:07 +01:00
Jannis Mattheis 80eec6ae3a Remove monkey dependency 2018-11-06 21:38:15 +01:00
Jannis Mattheis ae89184d76 Create sqlite3 db directory 2018-05-10 12:34:35 +02:00
Jannis Mattheis 1831b6078f [#34] Add db calls for paged message api 2018-04-13 18:56:11 +02:00
Jannis Mattheis c912bb8cba Delete Clients/Apps/Messages when deleting a user
sqlite3 doesn't support adding a foreign key via gorm.DB#AddForeignKey
this would mean, that we have some hacky solutions for having foreign
keys for sqlite and the other databases. Therefore manually deleting
the referencing models seems to be the best solution. We already have
interfaces for database capsuling, so no api must be adjusted.
2018-04-01 12:26:06 +02:00
Jannis Mattheis 61d5fc59a7 Add UploadApplicationImage API 2018-03-31 18:44:49 +02:00
Jannis Mattheis 8d7c7a5a50 Correctly delete all messages from a user
Till now only the ApplicationID got remove from the message, therefore
the message was still in the database but not visible for the user.
2018-03-25 19:33:29 +02:00
Jannis Mattheis 34f8cc6b77 Add create default user flag for testing 2018-03-25 19:33:29 +02:00
Jannis Mattheis 203791c63b Move password into own package to prevent package cycle 2018-03-25 19:33:29 +02:00
Jannis Mattheis d5d19b55bb Limit max db connections
While load testing mysql compained about too many connections.
2018-03-21 17:21:55 +01:00
Jannis Mattheis 2c9de20c2a Adjust message database impl 2018-03-11 17:58:44 +01:00
Jannis Mattheis a10fe96ea7 Adjust token database impl 2018-03-11 17:58:44 +01:00
Jannis Mattheis cda4127551 Make password strength configurable 2018-02-23 19:39:34 +01:00
Jannis Mattheis 1e7e1a71f7 Rename to gotify 2018-02-12 16:48:01 +01:00
Jannis Mattheis edec140c82 Limit sqlite to one connection
we use the database connection inside the handlers from the http
framework, therefore concurrent access occurs. Sqlite cannot handle
concurrent writes, so we limit sqlite to one connection.
see https://github.com/mattn/go-sqlite3/issues/274
2018-02-12 16:33:03 +01:00
Jannis Mattheis dffe12418b Add database wrapper 2018-02-11 08:54:20 +01:00