mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-15 08:41:26 +08:00

* feat: setup for licenses v3 integration * feat: added some more logic * feat: validator changes * chore: added a couple of todos * feat: added config parameter for licenses v3 and the boot option * feat: some typo fix * feat: added refresh licenses handler * feat: handle the start manager license activation * chore: text updates * feat: added list licenses call * chore: refactor the entire code to cleanup interfaces * fix: nil pointer error * chore: some minor edits * feat: model changes * feat: model changes * fix: utilise factory pattern * feat: added default basic plan * chore: added test cases for new license function * feat: added more test cases * chore: make the licenses id not null * feat: cosmetic changes * feat: cosmetic changes * feat: update zeus URL * chore: license testing fixes * feat: added license status and category handling for query-service * chore: added v3 support in v2 endpoint * chore: http response codes and some code cleanup * chore: added detailed test cases * chore: address review comments * chore: some misc cleanup
64 lines
1.3 KiB
Go
64 lines
1.3 KiB
Go
package sqlite
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
)
|
|
|
|
func InitDB(db *sqlx.DB) error {
|
|
var err error
|
|
if db == nil {
|
|
return fmt.Errorf("invalid db connection")
|
|
}
|
|
|
|
table_schema := `CREATE TABLE IF NOT EXISTS licenses(
|
|
key TEXT PRIMARY KEY,
|
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
planDetails TEXT,
|
|
activationId TEXT,
|
|
validationMessage TEXT,
|
|
lastValidated TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS sites(
|
|
uuid TEXT PRIMARY KEY,
|
|
alias VARCHAR(180) DEFAULT 'PROD',
|
|
url VARCHAR(300),
|
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
`
|
|
|
|
_, err = db.Exec(table_schema)
|
|
if err != nil {
|
|
return fmt.Errorf("error in creating licenses table: %s", err.Error())
|
|
}
|
|
|
|
table_schema = `CREATE TABLE IF NOT EXISTS feature_status (
|
|
name TEXT PRIMARY KEY,
|
|
active bool,
|
|
usage INTEGER DEFAULT 0,
|
|
usage_limit INTEGER DEFAULT 0,
|
|
route TEXT
|
|
);`
|
|
|
|
_, err = db.Exec(table_schema)
|
|
if err != nil {
|
|
return fmt.Errorf("error in creating feature_status table: %s", err.Error())
|
|
}
|
|
|
|
table_schema = `CREATE TABLE IF NOT EXISTS licenses_v3 (
|
|
id TEXT PRIMARY KEY,
|
|
key TEXT NOT NULL UNIQUE,
|
|
data TEXT
|
|
);`
|
|
|
|
_, err = db.Exec(table_schema)
|
|
if err != nil {
|
|
return fmt.Errorf("error in creating licenses_v3 table: %s", err.Error())
|
|
}
|
|
|
|
return nil
|
|
}
|