storj/multinode/multinodedb/migrate.go
Yaroslav Vorobiov ea7fbdf843 multinode/multinodedb: add db migration
Change-Id: Ied1a7f3b951a25ab7a8edc25902c0479d2d08e87
2021-05-13 15:44:08 +00:00

55 lines
1.2 KiB
Go

// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
package multinodedb
import (
"storj.io/storj/private/migrate"
)
// SQLite3Migration returns steps needed for migrating sqlite3 database.
func (db *DB) SQLite3Migration() *migrate.Migration {
return &migrate.Migration{
Table: "versions",
Steps: []*migrate.Step{
{
DB: &db.migrationDB,
Description: "Initial setup",
Version: 0,
Action: migrate.SQL{
`CREATE TABLE nodes (
id BLOB NOT NULL,
name TEXT NOT NULL,
public_address TEXT NOT NULL,
api_secret BLOB NOT NULL,
PRIMARY KEY ( id )
); `,
},
},
},
}
}
// PostgresMigration returns steps needed for migrating postgres database.
func (db *DB) PostgresMigration() *migrate.Migration {
return &migrate.Migration{
Table: "versions",
Steps: []*migrate.Step{
{
DB: &db.migrationDB,
Description: "Initial setup",
Version: 0,
Action: migrate.SQL{
`CREATE TABLE nodes (
id bytea NOT NULL,
name text NOT NULL,
public_address text NOT NULL,
api_secret bytea NOT NULL,
PRIMARY KEY ( id )
);`,
},
},
},
}
}