Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: oracle plugin skeleton (#4933)
Danny Xu6fa68b25b3af
diff --git a/backend/plugin/db/oracle/dump.go b/backend/plugin/db/oracle/dump.gonew file mode 100644index 0000000000..2e54685c4d--- /dev/null+++ b/backend/plugin/db/oracle/dump.go@@ -0,0 +1,18 @@+package snowflake++import (+ "context"+ "io"+)++// Dump dumps the database.+func (*Driver) Dump(_ context.Context, _ string, _ io.Writer, _ bool) (string, error) {+ // TODO(d): implement it.+ return "", nil+}++// Restore restores a database.+func (*Driver) Restore(_ context.Context, _ io.Reader) (err error) {+ // TODO(d): implement it.+ return nil+}diff --git a/backend/plugin/db/oracle/migrate.go b/backend/plugin/db/oracle/migrate.gonew file mode 100644index 0000000000..78344bd064--- /dev/null+++ b/backend/plugin/db/oracle/migrate.go@@ -0,0 +1,70 @@+package snowflake++import (+ "context"+ "database/sql"++ // embed will embeds the migration schema.+ _ "embed"++ "github.com/bytebase/bytebase/backend/plugin/db"+ "github.com/bytebase/bytebase/backend/plugin/db/util"+)++var (+ _ util.MigrationExecutor = (*Driver)(nil)+)++// NeedsSetupMigration returns whether it needs to setup migration.+func (*Driver) NeedsSetupMigration(_ context.Context) (bool, error) {+ // TODO(d): implement it.+ return false, nil+}++// SetupMigrationIfNeeded sets up migration if needed.+func (*Driver) SetupMigrationIfNeeded(_ context.Context) error {+ // TODO(d): implement it.+ return nil+}++// FindLargestVersionSinceBaseline will find the largest version since last baseline or branch.+func (Driver) FindLargestVersionSinceBaseline(_ context.Context, _ *sql.Tx, _ string) (*string, error) {+ // TODO(d): implement it.+ return nil, nil+}++// FindLargestSequence will return the largest sequence number.+func (Driver) FindLargestSequence(_ context.Context, _ *sql.Tx, _ string, _ bool) (int, error) {+ // TODO(d): implement it.+ return 0, nil+}++// InsertPendingHistory will insert the migration record with pending status and return the inserted ID.+func (Driver) InsertPendingHistory(_ context.Context, _ *sql.Tx, _ int, _ string, _ *db.MigrationInfo, _, _ string) (string, error) {+ // TODO(d): implement it.+ return "", nil+}++// UpdateHistoryAsDone will update the migration record as done.+func (Driver) UpdateHistoryAsDone(_ context.Context, _ *sql.Tx, _ int64, _ string, _ string) error {+ // TODO(d): implement it.+ return nil+}++// UpdateHistoryAsFailed will update the migration record as failed.+func (Driver) UpdateHistoryAsFailed(_ context.Context, _ *sql.Tx, _ int64, _ string) error {+ // TODO(d): implement it.+ return nil+}++// ExecuteMigration will execute the migration.+func (*Driver) ExecuteMigration(_ context.Context, _ *db.MigrationInfo, _ string) (string, string, error) {+ // TODO(d): implement it.+ return "", "", nil+}++// FindMigrationHistoryList finds the migration history.+func (*Driver) FindMigrationHistoryList(_ context.Context, _ *db.MigrationHistoryFind) ([]*db.MigrationHistory, error) {+ // TODO(d): implement it.+ return nil, nil+}diff --git a/backend/plugin/db/oracle/oracle.go b/backend/plugin/db/oracle/oracle.gonew file mode 100644index 0000000000..9bcbda79a9--- /dev/null+++ b/backend/plugin/db/oracle/oracle.go@@ -0,0 +1,66 @@+// Package snowflake is the plugin for Snowflake driver.+package snowflake++import (+ "context"+ "database/sql"++ "github.com/bytebase/bytebase/backend/plugin/db"+)++var (+ _ db.Driver = (*Driver)(nil)+)++func init() {+ db.Register(db.Oracle, newDriver)+}++// Driver is the Oracle driver.+type Driver struct {+}++func newDriver(db.DriverConfig) db.Driver {+ return &Driver{}+}++// Open opens a Snowflake driver.+func (*Driver) Open(_ context.Context, _ db.Type, _ db.ConnectionConfig, _ db.ConnectionContext) (db.Driver, error) {+ // TODO(d): implement it.+ return nil, nil+}++// Close closes the driver.+func (*Driver) Close(_ context.Context) error {+ // TODO(d): implement it.+ return nil+}++// Ping pings the database.+func (*Driver) Ping(_ context.Context) error {+ // TODO(d): implement it.+ return nil+}++// GetType returns the database type.+func (*Driver) GetType() db.Type {+ return db.Oracle+}++// GetDBConnection gets a database connection.+func (*Driver) GetDBConnection(_ context.Context, _ string) (*sql.DB, error) {+ // TODO(d): implement it.+ return nil, nil+}++// Execute executes a SQL statement and returns the affected rows.+func (*Driver) Execute(_ context.Context, _ string, _ bool) (int64, error) {+ // TODO(d): implement it.+ return 0, nil+}++// QueryConn querys a SQL statement in a given connection.+func (*Driver) QueryConn(_ context.Context, _ *sql.Conn, _ string, _ *db.QueryContext) ([]interface{}, error) {+ // TODO(d): implement it.+ return nil, nil+}diff --git a/backend/plugin/db/oracle/oracle_migration_schema.sql b/backend/plugin/db/oracle/oracle_migration_schema.sqlnew file mode 100644index 0000000000..c137c7e49e--- /dev/null+++ b/backend/plugin/db/oracle/oracle_migration_schema.sql@@ -0,0 +1,2 @@+-- This is the bytebase schema to track migration info for Oracle+-- Create a database called bytebasediff --git a/backend/plugin/db/oracle/role.go b/backend/plugin/db/oracle/role.gonew file mode 100644index 0000000000..897d3446d8--- /dev/null+++ b/backend/plugin/db/oracle/role.go@@ -0,0 +1,34 @@+package snowflake++import (+ "context"++ "github.com/pkg/errors"++ "github.com/bytebase/bytebase/backend/plugin/db"+)++// CreateRole creates the role.+func (*Driver) CreateRole(_ context.Context, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {+ return nil, errors.Errorf("create role for Oracle is not implemented yet")+}++// UpdateRole updates the role.+func (*Driver) UpdateRole(_ context.Context, _ string, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {+ return nil, errors.Errorf("update role for Oracle is not implemented yet")+}++// FindRole finds the role by name.+func (*Driver) FindRole(_ context.Context, _ string) (*db.DatabaseRoleMessage, error) {+ return nil, errors.Errorf("find role for Oracle is not implemented yet")+}++// ListRole lists the role.+func (*Driver) ListRole(_ context.Context) ([]*db.DatabaseRoleMessage, error) {+ return nil, errors.Errorf("list role for Oracle is not implemented yet")+}++// DeleteRole deletes the role by name.+func (*Driver) DeleteRole(_ context.Context, _ string) error {+ return errors.Errorf("delete role for Oracle is not implemented yet")+}diff --git a/backend/plugin/db/oracle/sync.go b/backend/plugin/db/oracle/sync.gonew file mode 100644index 0000000000..4bda5f7827--- /dev/null+++ b/backend/plugin/db/oracle/sync.go@@ -0,0 +1,20 @@+package snowflake++import (+ "context"++ "github.com/bytebase/bytebase/backend/plugin/db"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store"+)++// SyncInstance syncs the instance.+func (*Driver) SyncInstance(_ context.Context) (*db.InstanceMetadata, error) {+ // TODO(d): implement it.+ return nil, nil+}++// SyncDBSchema syncs a single database schema.+func (*Driver) SyncDBSchema(_ context.Context, _ string) (*storepb.DatabaseMetadata, error) {+ // TODO(d): implement it.+ return nil, nil+}