diff --git a/cmd/cmd_db.go b/cmd/cmd_db.go index a8ba8e6f..f1d5e896 100644 --- a/cmd/cmd_db.go +++ b/cmd/cmd_db.go @@ -1,9 +1,6 @@ package main import ( - "database/sql" - "fmt" - "github.com/spf13/cobra" ) @@ -13,20 +10,6 @@ func dbCmd() *cobra.Command { Short: "Create, setup, migrate, seed the database", } - c1 := &cobra.Command{ - Use: "create", - Short: "Create database", - Run: cmdDBCreate, - } - c.AddCommand(c1) - - c2 := &cobra.Command{ - Use: "drop", - Short: "Drop database", - Run: cmdDBDrop, - } - c.AddCommand(c2) - c.AddCommand(migrateCmd()) c3 := &cobra.Command{ @@ -44,14 +27,6 @@ func dbCmd() *cobra.Command { } c.AddCommand(c4) - c5 := &cobra.Command{ - Use: "reset", - Short: "Reset database", - Long: "This command will drop, create, migrate and seed the database (won't run in production)", - Run: cmdDBReset, - } - c.AddCommand(c5) - return c } @@ -62,62 +37,6 @@ func cmdDBSetup(cmd *cobra.Command, args []string) { log.Fatal("Database setup not support with MySQL") } - cmdDBCreate(cmd, []string{}) cmdDBMigrate(cmd, []string{"up"}) cmdDBSeed(cmd, []string{}) } - -func cmdDBReset(cmd *cobra.Command, args []string) { - setup(cpath) - - if conf.Serv.Production { - log.Fatal("Command db:reset does not work in production") - } - - cmdDBDrop(cmd, []string{}) - cmdDBSetup(cmd, []string{}) -} - -func cmdDBCreate(cmd *cobra.Command, args []string) { - setup(cpath) - initDB(false) - - if conf.DB.Type == "mysql" { - log.Fatalf("Database creation not support with MySQL") - } - - dbName := conf.DB.DBName - dbExists := false - - err := db. - QueryRow(`SELECT true as exists FROM pg_database WHERE datname = $1;`, dbName). - Scan(&dbExists) - - if err != nil && err != sql.ErrNoRows { - log.Fatalf("Error checking if database exists: %s", err) - } - - if dbExists { - log.Infof("Database exists: %s", dbName) - return - } - - if _, err = db.Exec(`CREATE DATABASE "` + dbName + `"`); err != nil { - log.Fatalf("Failed to create database: %s", err) - } - - log.Infof("Created database: %s", dbName) -} - -func cmdDBDrop(cmd *cobra.Command, args []string) { - setup(cpath) - initDB(false) - - sql := fmt.Sprintf(`DROP DATABASE IF EXISTS "%s"`, conf.DB.DBName) - - if _, err := db.Exec(sql); err != nil { - log.Fatalf("Failed to drop database: %s", err) - } - - log.Infof("Database dropped: %s", conf.DB.DBName) -} diff --git a/cmd/cmd_seed.go b/cmd/cmd_seed.go index 8519d101..2d427fb5 100644 --- a/cmd/cmd_seed.go +++ b/cmd/cmd_seed.go @@ -99,7 +99,6 @@ func compileAndRunJS(seed string, db *sql.DB) error { "plugins": []string{ "proposal-async-generator-functions", "proposal-class-properties", - "proposal-dynamic-import", "proposal-json-strings", "proposal-nullish-coalescing-operator", "proposal-numeric-separator", @@ -327,7 +326,6 @@ func importCSV(table, filename string, sep string, db *sql.DB) int64 { pgx.Identifier{table}, cols, s) - if err != nil { err = fmt.Errorf("%w (line no %d)", err, s.i) log.Fatalf("Error with copy-from: %s", err) diff --git a/go.work.sum b/go.work.sum index df7621d9..3c2e02de 100644 --- a/go.work.sum +++ b/go.work.sum @@ -861,6 +861,7 @@ github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwX github.com/jackc/pgproto3/v2 v2.3.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag= github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= diff --git a/serv/db.go b/serv/db.go index 6d7f76b8..f0e122c3 100644 --- a/serv/db.go +++ b/serv/db.go @@ -125,9 +125,9 @@ func initPostgres(conf *Config, openDB, useTelemetry bool, fs core.FS) (*dbConf, config.RuntimeParams["application_name"] = c.AppName } - if openDB { - config.Database = c.DB.DBName - } + // if openDB { + config.Database = c.DB.DBName + // } if c.DB.EnableTLS { if len(c.DB.ServerName) == 0 { diff --git a/serv/go.mod b/serv/go.mod index 9b525ecb..c3a4180d 100644 --- a/serv/go.mod +++ b/serv/go.mod @@ -11,14 +11,14 @@ require ( github.com/fsnotify/fsnotify v1.7.0 github.com/go-http-utils/headers v0.0.0-20181008091004-fed159eddc2a github.com/go-pkgz/expirable-cache v1.0.0 - github.com/go-resty/resty/v2 v2.13.0 + github.com/go-resty/resty/v2 v2.13.1 github.com/go-sql-driver/mysql v1.8.1 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/gorilla/websocket v1.5.1 github.com/invopop/jsonschema v0.12.0 - github.com/jackc/pgx/v5 v5.5.5 + github.com/jackc/pgx/v5 v5.6.0 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 - github.com/klauspost/compress v1.17.8 + github.com/klauspost/compress v1.17.9 github.com/pkg/errors v0.9.1 github.com/rs/cors v1.11.0 github.com/spf13/afero v1.11.0 diff --git a/serv/go.sum b/serv/go.sum index 2cf058f6..355e25b3 100644 --- a/serv/go.sum +++ b/serv/go.sum @@ -119,6 +119,8 @@ github.com/go-pkgz/expirable-cache v1.0.0 h1:ns5+1hjY8hntGv8bPaQd9Gr7Jyo+Uw5SLyI github.com/go-pkgz/expirable-cache v1.0.0/go.mod h1:GTrEl0X+q0mPNqN6dtcQXksACnzCBQ5k/k1SwXJsZKs= github.com/go-resty/resty/v2 v2.13.0 h1:joaL6wxSgm1OZal4FAAyddkL1T4uo5NxHYFkGmUusqE= github.com/go-resty/resty/v2 v2.13.0/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0= +github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g= +github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= @@ -207,6 +209,8 @@ github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= +github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY= +github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw= github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -218,6 +222,8 @@ github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uia github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= diff --git a/wasm/graphjin.wasm b/wasm/graphjin.wasm index 70534e2e..92882849 100755 Binary files a/wasm/graphjin.wasm and b/wasm/graphjin.wasm differ