MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / SQLRestore

Method SQLRestore

tools/mage/dev.go:121–136  ·  view source on GitHub ↗

SQLRestore restores the dev database using a previously generated dump.

()

Source from the content-addressed store, hash-verified

119
120// SQLRestore restores the dev database using a previously generated dump.
121func (Dev) SQLRestore() error {
122 if mg.Verbose() {
123 fmt.Println("Restoring database from dump")
124 }
125 d := filepath.Join(".env", "cache", "database.pgdump")
126 if _, err := os.Stat(d); errors.Is(err, os.ErrNotExist) {
127 return fmt.Errorf("Dumpfile does not exist: %w", d)
128 }
129 return execDockerCompose("exec", "-T", "postgres", "/bin/bash", "-c",
130 strings.Join([]string{
131 fmt.Sprintf("dropdb --if-exists --force %s", devDatabaseName),
132 fmt.Sprintf("createdb %s", devDatabaseName),
133 fmt.Sprintf("pg_restore -d %s -Fc /var/lib/ttn-lorawan/cache/database.pgdump", devDatabaseName),
134 }, " && "),
135 )
136}
137
138// RedisFlush deletes all keys from redis except specific task queues.
139func (Dev) RedisFlush() error {

Callers

nothing calls this directly

Calls 4

execDockerComposeFunction · 0.85
JoinMethod · 0.65
ErrorfMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected