Documentation ¶
Index ¶
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 AutoApprove bool } // 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 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?sslmode=disable" -f atlas.hcl atlas schema apply -d "sqlite://file:ex1.db?_fk=1" -f atlas.hcl`, } )
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?sslmode=disable" 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 canonical 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 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.