2019-05-09 06:58:55 +00:00
|
|
|
package common
|
|
|
|
|
Cascade delete attachments properly.
Cascade delete replied to topic events for replies properly.
Cascade delete likes on topic posts properly.
Cascade delete replies and their children properly.
Recalculate user stats properly when items are deleted.
Users can now unlike topic opening posts.
Add a recalculator to fix abnormalities across upgrades.
Try fixing a last_ip daily update bug.
Add Existable interface.
Add Delete method to LikeStore.
Add Each, Exists, Create, CountUser, CountMegaUser and CountBigUser methods to ReplyStore.
Add CountUser, CountMegaUser, CountBigUser methods to TopicStore.
Add Each method to UserStore.
Add Add, Delete and DeleteResource methods to SubscriptionStore.
Add Delete, DeleteByParams, DeleteByParamsExtra and AidsByParamsExtra methods to ActivityStream.
Add Exists method to ProfileReplyStore.
Add DropColumn, RenameColumn and ChangeColumn to the database adapters.
Shorten ipaddress column names to ip.
- topics table.
- replies table
- users_replies table.
- polls_votes table.
Add extra column to activity_stream table.
Fix an issue upgrading sites to MariaDB 10.3 from older versions of Gosora. Please report any other issues you find.
You need to run the updater / patcher for this commit.
2020-01-31 07:22:08 +00:00
|
|
|
import (
|
|
|
|
"database/sql"
|
2019-05-09 06:58:55 +00:00
|
|
|
|
Cascade delete attachments properly.
Cascade delete replied to topic events for replies properly.
Cascade delete likes on topic posts properly.
Cascade delete replies and their children properly.
Recalculate user stats properly when items are deleted.
Users can now unlike topic opening posts.
Add a recalculator to fix abnormalities across upgrades.
Try fixing a last_ip daily update bug.
Add Existable interface.
Add Delete method to LikeStore.
Add Each, Exists, Create, CountUser, CountMegaUser and CountBigUser methods to ReplyStore.
Add CountUser, CountMegaUser, CountBigUser methods to TopicStore.
Add Each method to UserStore.
Add Add, Delete and DeleteResource methods to SubscriptionStore.
Add Delete, DeleteByParams, DeleteByParamsExtra and AidsByParamsExtra methods to ActivityStream.
Add Exists method to ProfileReplyStore.
Add DropColumn, RenameColumn and ChangeColumn to the database adapters.
Shorten ipaddress column names to ip.
- topics table.
- replies table
- users_replies table.
- polls_votes table.
Add extra column to activity_stream table.
Fix an issue upgrading sites to MariaDB 10.3 from older versions of Gosora. Please report any other issues you find.
You need to run the updater / patcher for this commit.
2020-01-31 07:22:08 +00:00
|
|
|
qgen "github.com/Azareal/Gosora/query_gen"
|
|
|
|
)
|
2019-05-09 06:58:55 +00:00
|
|
|
|
|
|
|
// MetaStore is a simple key-value store for the system to stash things in when needed
|
|
|
|
type MetaStore interface {
|
|
|
|
Get(name string) (val string, err error)
|
Cascade delete attachments properly.
Cascade delete replied to topic events for replies properly.
Cascade delete likes on topic posts properly.
Cascade delete replies and their children properly.
Recalculate user stats properly when items are deleted.
Users can now unlike topic opening posts.
Add a recalculator to fix abnormalities across upgrades.
Try fixing a last_ip daily update bug.
Add Existable interface.
Add Delete method to LikeStore.
Add Each, Exists, Create, CountUser, CountMegaUser and CountBigUser methods to ReplyStore.
Add CountUser, CountMegaUser, CountBigUser methods to TopicStore.
Add Each method to UserStore.
Add Add, Delete and DeleteResource methods to SubscriptionStore.
Add Delete, DeleteByParams, DeleteByParamsExtra and AidsByParamsExtra methods to ActivityStream.
Add Exists method to ProfileReplyStore.
Add DropColumn, RenameColumn and ChangeColumn to the database adapters.
Shorten ipaddress column names to ip.
- topics table.
- replies table
- users_replies table.
- polls_votes table.
Add extra column to activity_stream table.
Fix an issue upgrading sites to MariaDB 10.3 from older versions of Gosora. Please report any other issues you find.
You need to run the updater / patcher for this commit.
2020-01-31 07:22:08 +00:00
|
|
|
Set(name, val string) error
|
2021-04-27 10:20:26 +00:00
|
|
|
SetInt(name string, val int) error
|
|
|
|
SetInt64(name string, val int64) error
|
2019-05-09 06:58:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type DefaultMetaStore struct {
|
|
|
|
get *sql.Stmt
|
|
|
|
set *sql.Stmt
|
|
|
|
add *sql.Stmt
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDefaultMetaStore(acc *qgen.Accumulator) (*DefaultMetaStore, error) {
|
2021-04-27 10:20:26 +00:00
|
|
|
t := "meta"
|
2019-05-09 06:58:55 +00:00
|
|
|
m := &DefaultMetaStore{
|
2021-04-27 10:20:26 +00:00
|
|
|
get: acc.Select(t).Columns("value").Where("name=?").Prepare(),
|
|
|
|
set: acc.Update(t).Set("value=?").Where("name=?").Prepare(),
|
|
|
|
add: acc.Insert(t).Columns("name,value").Fields("?,''").Prepare(),
|
2019-05-09 06:58:55 +00:00
|
|
|
}
|
|
|
|
return m, acc.FirstError()
|
|
|
|
}
|
|
|
|
|
2021-04-27 10:20:26 +00:00
|
|
|
func (s *DefaultMetaStore) Get(name string) (val string, e error) {
|
|
|
|
e = s.get.QueryRow(name).Scan(&val)
|
|
|
|
return val, e
|
2019-05-09 06:58:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Use timestamped rows as a more robust method of ensuring data integrity
|
2021-04-27 10:20:26 +00:00
|
|
|
func (s *DefaultMetaStore) setVal(name string, val interface{}) error {
|
|
|
|
_, e := s.Get(name)
|
|
|
|
if e == sql.ErrNoRows {
|
|
|
|
_, e := s.add.Exec(name)
|
|
|
|
if e != nil {
|
|
|
|
return e
|
2019-05-09 06:58:55 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-27 10:20:26 +00:00
|
|
|
_, e = s.set.Exec(val, name)
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DefaultMetaStore) Set(name, val string) error {
|
|
|
|
return s.setVal(name, val)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DefaultMetaStore) SetInt(name string, val int) error {
|
|
|
|
return s.setVal(name, val)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DefaultMetaStore) SetInt64(name string, val int64) error {
|
|
|
|
return s.setVal(name, val)
|
2019-05-09 06:58:55 +00:00
|
|
|
}
|