Documentation ¶
Index ¶
- Variables
- func CheckForUpdate()
- func CmdApplyRun(cmd *cobra.Command, args []string)
- func CmdDiffRun(cmd *cobra.Command, args []string)
- func CmdFmtRun(cmd *cobra.Command, args []string)
- func CmdInspectRun(_ *cobra.Command, _ []string)
- func SchemaNameFromDSN(url string) (string, error)
- type Driver
- type Mux
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ApplyFlags are the flags used in Apply command. ApplyFlags struct { DSN string File string Web bool Addr string DryRun bool Schema []string } // ApplyCmd represents the apply command. ApplyCmd = &cobra.Command{ Use: "apply", Short: "Apply an atlas schema to a target database.", Long: "`atlas schema apply`" + ` plans and executes a database migration to be bring a given database to the state described in the Atlas schema file. Before running the migration, Atlas will print the migration plan and prompt the user for approval. If run with the "--dry-run" flag, atlas will exit after printing out the planned migration.`, Run: CmdApplyRun, Example: `atlas schema apply -d "mysql://user:pass@tcp(localhost:3306)/dbname" -f atlas.hcl atlas schema apply -d "mysql://user:pass@tcp(localhost:3306)/" -f atlas.hcl --schema prod --schema staging atlas schema apply -d "mysql://user:pass@tcp(localhost:3306)/dbname" -f atlas.hcl --dry-run atlas schema apply -d "mariadb://user:pass@tcp(localhost:3306)/dbname" -f atlas.hcl atlas schema apply --dsn "postgres://user:pass@host:port/dbname" -f atlas.hcl atlas schema apply -d "sqlite://file:ex1.db?_fk=1" -f atlas.hcl`, } )
View Source
var ( // DiffFlags are the flags used in the Diff command. DiffFlags struct { FromDSN string ToDSN string } // DiffCmd represents the diff command. DiffCmd = &cobra.Command{ Use: "diff", Short: "Calculate and print the diff between two schemas.", Long: "`atlas schema diff`" + ` connects to two given databases, inspects them, calculates the difference in their schemas, and prints a plan of SQL queries to bring the "from" database to the schema of the "to" database.`, Run: CmdDiffRun, } )
View Source
var ( // InspectFlags are the flags used in Inspect command. InspectFlags struct { DSN string Web bool Addr string Schema []string } // InspectCmd represents the inspect command. InspectCmd = &cobra.Command{ Use: "inspect", Short: "Inspect an a database's and print its schema in Atlas DDL syntax.", Long: "`atlas schema inspect`" + ` connects to the given database and inspects its schema. It then prints to the screen the schema of that database in Atlas DDL syntax. This output can be saved to a file, commonly by redirecting the output to a file named with a ".hcl" suffix: atlas schema inspect -d "mysql://user:pass@tcp(localhost:3306)/dbname" > atlas.hcl This file can then be edited and used with the` + " `atlas schema apply` " + `command to plan and execute schema migrations against the given database. In cases where users wish to inspect all multiple schemas in a given database (for instance a MySQL server may contain multiple named databases), omit the relevant part from the dsn, e.g. "mysql://user:pass@tcp(localhost:3306)/". To select specific schemas from the databases, users may use the "--schema" (or "-s" shorthand) flag. `, Run: CmdInspectRun, Example: ` atlas schema inspect -d "mysql://user:pass@tcp(localhost:3306)/dbname" atlas schema inspect -d "mariadb://user:pass@tcp(localhost:3306)/" --schema=schemaA,schemaB -s schemaC atlas schema inspect --dsn "postgres://user:pass@host:port/dbname" atlas schema inspect -d "sqlite://file:ex1.db?_fk=1"`, } )
View Source
var ( // FmtCmd represents the fmt command. FmtCmd = &cobra.Command{ Use: "fmt [path ...]", Short: "Formats Atlas HCL files", Long: "`atlas schema fmt`" + ` formats all ".hcl" files under the given path using cannonical HCL layout style as defined by the github.com/hashicorp/hcl/v2/hclwrite package. Unless stated otherwise, the fmt command will use the current directory. After running, the command will print the names of the files it has formatted. If all files in the directory are formatted, no input will be printed out. `, Run: CmdFmtRun, } )
View Source
var RootCmd = &cobra.Command{
Use: "atlas",
Short: "A database toolkit.",
}
RootCmd represents the base command when called without any subcommands
Functions ¶
func CmdApplyRun ¶
CmdApplyRun is the command used when running CLI.
func CmdDiffRun ¶ added in v0.3.2
CmdDiffRun connects to the given databases, and prints an SQL plan to get from the "from" schema to the "to" schema.
func CmdFmtRun ¶ added in v0.3.2
CmdFmtRun formats all HCL files in a given directory using canonical HCL formatting rules.
func CmdInspectRun ¶
CmdInspectRun is the command used when running CLI.
func SchemaNameFromDSN ¶
SchemaNameFromDSN parses the dsn the returns schema name
Types ¶
type Driver ¶
type Driver struct { migrate.Driver schemaspec.Marshaler schemaspec.Unmarshaler }
Driver implements the Atlas interface.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.