Skip to content

Commit 3cdc218

Browse files
committed
fix: removed db create / reset/ drop and upraded libs
1 parent ef33473 commit 3cdc218

File tree

7 files changed

+13
-89
lines changed

7 files changed

+13
-89
lines changed

cmd/cmd_db.go

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package main
22

33
import (
4-
"database/sql"
5-
"fmt"
6-
74
"github.com/spf13/cobra"
85
)
96

@@ -13,20 +10,6 @@ func dbCmd() *cobra.Command {
1310
Short: "Create, setup, migrate, seed the database",
1411
}
1512

16-
c1 := &cobra.Command{
17-
Use: "create",
18-
Short: "Create database",
19-
Run: cmdDBCreate,
20-
}
21-
c.AddCommand(c1)
22-
23-
c2 := &cobra.Command{
24-
Use: "drop",
25-
Short: "Drop database",
26-
Run: cmdDBDrop,
27-
}
28-
c.AddCommand(c2)
29-
3013
c.AddCommand(migrateCmd())
3114

3215
c3 := &cobra.Command{
@@ -44,14 +27,6 @@ func dbCmd() *cobra.Command {
4427
}
4528
c.AddCommand(c4)
4629

47-
c5 := &cobra.Command{
48-
Use: "reset",
49-
Short: "Reset database",
50-
Long: "This command will drop, create, migrate and seed the database (won't run in production)",
51-
Run: cmdDBReset,
52-
}
53-
c.AddCommand(c5)
54-
5530
return c
5631
}
5732

@@ -62,62 +37,6 @@ func cmdDBSetup(cmd *cobra.Command, args []string) {
6237
log.Fatal("Database setup not support with MySQL")
6338
}
6439

65-
cmdDBCreate(cmd, []string{})
6640
cmdDBMigrate(cmd, []string{"up"})
6741
cmdDBSeed(cmd, []string{})
6842
}
69-
70-
func cmdDBReset(cmd *cobra.Command, args []string) {
71-
setup(cpath)
72-
73-
if conf.Serv.Production {
74-
log.Fatal("Command db:reset does not work in production")
75-
}
76-
77-
cmdDBDrop(cmd, []string{})
78-
cmdDBSetup(cmd, []string{})
79-
}
80-
81-
func cmdDBCreate(cmd *cobra.Command, args []string) {
82-
setup(cpath)
83-
initDB(false)
84-
85-
if conf.DB.Type == "mysql" {
86-
log.Fatalf("Database creation not support with MySQL")
87-
}
88-
89-
dbName := conf.DB.DBName
90-
dbExists := false
91-
92-
err := db.
93-
QueryRow(`SELECT true as exists FROM pg_database WHERE datname = $1;`, dbName).
94-
Scan(&dbExists)
95-
96-
if err != nil && err != sql.ErrNoRows {
97-
log.Fatalf("Error checking if database exists: %s", err)
98-
}
99-
100-
if dbExists {
101-
log.Infof("Database exists: %s", dbName)
102-
return
103-
}
104-
105-
if _, err = db.Exec(`CREATE DATABASE "` + dbName + `"`); err != nil {
106-
log.Fatalf("Failed to create database: %s", err)
107-
}
108-
109-
log.Infof("Created database: %s", dbName)
110-
}
111-
112-
func cmdDBDrop(cmd *cobra.Command, args []string) {
113-
setup(cpath)
114-
initDB(false)
115-
116-
sql := fmt.Sprintf(`DROP DATABASE IF EXISTS "%s"`, conf.DB.DBName)
117-
118-
if _, err := db.Exec(sql); err != nil {
119-
log.Fatalf("Failed to drop database: %s", err)
120-
}
121-
122-
log.Infof("Database dropped: %s", conf.DB.DBName)
123-
}

cmd/cmd_seed.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func compileAndRunJS(seed string, db *sql.DB) error {
9999
"plugins": []string{
100100
"proposal-async-generator-functions",
101101
"proposal-class-properties",
102-
"proposal-dynamic-import",
103102
"proposal-json-strings",
104103
"proposal-nullish-coalescing-operator",
105104
"proposal-numeric-separator",
@@ -327,7 +326,6 @@ func importCSV(table, filename string, sep string, db *sql.DB) int64 {
327326
pgx.Identifier{table},
328327
cols,
329328
s)
330-
331329
if err != nil {
332330
err = fmt.Errorf("%w (line no %d)", err, s.i)
333331
log.Fatalf("Error with copy-from: %s", err)

go.work.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwX
861861
github.com/jackc/pgproto3/v2 v2.3.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
862862
github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag=
863863
github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
864+
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
864865
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
865866
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
866867
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=

serv/db.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ func initPostgres(conf *Config, openDB, useTelemetry bool, fs core.FS) (*dbConf,
125125
config.RuntimeParams["application_name"] = c.AppName
126126
}
127127

128-
if openDB {
129-
config.Database = c.DB.DBName
130-
}
128+
// if openDB {
129+
config.Database = c.DB.DBName
130+
// }
131131

132132
if c.DB.EnableTLS {
133133
if len(c.DB.ServerName) == 0 {

serv/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ require (
1111
github.com/fsnotify/fsnotify v1.7.0
1212
github.com/go-http-utils/headers v0.0.0-20181008091004-fed159eddc2a
1313
github.com/go-pkgz/expirable-cache v1.0.0
14-
github.com/go-resty/resty/v2 v2.13.0
14+
github.com/go-resty/resty/v2 v2.13.1
1515
github.com/go-sql-driver/mysql v1.8.1
1616
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
1717
github.com/gorilla/websocket v1.5.1
1818
github.com/invopop/jsonschema v0.12.0
19-
github.com/jackc/pgx/v5 v5.5.5
19+
github.com/jackc/pgx/v5 v5.6.0
2020
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
21-
github.com/klauspost/compress v1.17.8
21+
github.com/klauspost/compress v1.17.9
2222
github.com/pkg/errors v0.9.1
2323
github.com/rs/cors v1.11.0
2424
github.com/spf13/afero v1.11.0

serv/go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ github.com/go-pkgz/expirable-cache v1.0.0 h1:ns5+1hjY8hntGv8bPaQd9Gr7Jyo+Uw5SLyI
119119
github.com/go-pkgz/expirable-cache v1.0.0/go.mod h1:GTrEl0X+q0mPNqN6dtcQXksACnzCBQ5k/k1SwXJsZKs=
120120
github.com/go-resty/resty/v2 v2.13.0 h1:joaL6wxSgm1OZal4FAAyddkL1T4uo5NxHYFkGmUusqE=
121121
github.com/go-resty/resty/v2 v2.13.0/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0=
122+
github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g=
123+
github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0=
122124
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
123125
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
124126
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
207209
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
208210
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
209211
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
212+
github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
213+
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
210214
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
211215
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
212216
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
218222
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
219223
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
220224
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
225+
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
226+
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
221227
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
222228
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
223229
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=

wasm/graphjin.wasm

1.67 KB
Binary file not shown.

0 commit comments

Comments
 (0)