From 1cb257bfcf9d9ca714853f98c7bd265391887b82 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki Date: Sun, 28 Jul 2024 19:13:44 +0300 Subject: [PATCH] cmd/atlas/internal/cmdext: delete used testdata --- cmd/atlas/go.mod | 4 +- cmd/atlas/go.sum | 6 +- .../cmdext/testdata/schema/revision.go | 66 ------------------- cmd/atlas/internal/migrate/ent/ent.go | 2 +- .../internal/migrate/ent/revision_query.go | 21 +++--- .../internal/migrate/ent/runtime/runtime.go | 4 +- 6 files changed, 20 insertions(+), 83 deletions(-) delete mode 100644 cmd/atlas/internal/cmdext/testdata/schema/revision.go diff --git a/cmd/atlas/go.mod b/cmd/atlas/go.mod index 909f8123850..284cfb785f3 100644 --- a/cmd/atlas/go.mod +++ b/cmd/atlas/go.mod @@ -6,11 +6,12 @@ replace ariga.io/atlas => ../.. require ( ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 - entgo.io/ent v0.13.0 + entgo.io/ent v0.13.2-0.20240728160047-15bebe8d8920 github.com/1lann/promptui v0.8.1-0.20220708222609-81fad96dd5e1 github.com/antlr4-go/antlr/v4 v4.13.0 github.com/aws/aws-sdk-go-v2/config v1.26.1 github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.16 + github.com/chzyer/readline v1.5.1 github.com/fatih/color v1.13.0 github.com/go-sql-driver/mysql v1.7.1 github.com/google/uuid v1.6.0 @@ -58,7 +59,6 @@ require ( github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.5 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.26.5 // indirect github.com/aws/smithy-go v1.19.0 // indirect - github.com/chzyer/readline v1.5.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-openapi/inflect v0.19.0 // indirect diff --git a/cmd/atlas/go.sum b/cmd/atlas/go.sum index 7f23cda5085..7f1944cca8b 100644 --- a/cmd/atlas/go.sum +++ b/cmd/atlas/go.sum @@ -13,8 +13,8 @@ cloud.google.com/go/longrunning v0.5.4 h1:w8xEcbZodnA2BbW6sVirkkoC+1gP8wS57EUUgG cloud.google.com/go/longrunning v0.5.4/go.mod h1:zqNVncI0BOP8ST6XQD1+VcvuShMmq7+xFSzOL++V0dI= cloud.google.com/go/secretmanager v1.11.4 h1:krnX9qpG2kR2fJ+u+uNyNo+ACVhplIAS4Pu7u+4gd+k= cloud.google.com/go/secretmanager v1.11.4/go.mod h1:wreJlbS9Zdq21lMzWmJ0XhWW2ZxgPeahsqeV/vZoJ3w= -entgo.io/ent v0.13.0 h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE= -entgo.io/ent v0.13.0/go.mod h1:+oU8oGna69xy29O+g+NEz+/TM7yJDhQQGJfuOWq1pT8= +entgo.io/ent v0.13.2-0.20240728160047-15bebe8d8920 h1:nbro7OIsADbHVgau1PWC19QCZNDyin5pMOJabt0kWcs= +entgo.io/ent v0.13.2-0.20240728160047-15bebe8d8920/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A= github.com/1lann/promptui v0.8.1-0.20220708222609-81fad96dd5e1 h1:LejjvYg4tCW5HO7q/1nzPrprh47oUD9OUySQ29pDp5c= github.com/1lann/promptui v0.8.1-0.20220708222609-81fad96dd5e1/go.mod h1:cnC/60IoLiDM0GhdKYJ6oO7AwpZe1IQfPnSKlAURgHw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -340,6 +340,8 @@ golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= diff --git a/cmd/atlas/internal/cmdext/testdata/schema/revision.go b/cmd/atlas/internal/cmdext/testdata/schema/revision.go deleted file mode 100644 index 527ad1aad0c..00000000000 --- a/cmd/atlas/internal/cmdext/testdata/schema/revision.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2021-present The Atlas Authors. All rights reserved. -// This source code is licensed under the Apache 2.0 license found -// in the LICENSE file in the root directory of this source tree. - -//go:build testdata -// +build testdata - -package schema - -import ( - "time" - - "ariga.io/atlas/sql/migrate" - - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/field" -) - -// DefaultRevisionSchema is the default schema for storing revisions table. -const DefaultRevisionSchema = "atlas_schema_revisions" - -// Revision holds the schema definition for the Revision entity. -type Revision struct { - ent.Schema -} - -// Fields of the Revision. -func (Revision) Fields() []ent.Field { - return []ent.Field{ - field.String("id"). - StorageKey("version"). - Immutable(), - field.String("description"). - Immutable(), - field.Uint("type"). - GoType(migrate.RevisionType(0)). - Default(uint(migrate.RevisionTypeExecute)), - field.Int("applied"). - NonNegative(). - Default(0), - field.Int("total"). - NonNegative(). - Default(0), - field.Time("executed_at"). - Immutable(), - field.Int64("execution_time"). - GoType(time.Duration(0)), - field.Text("error"). - Optional(), - field.Text("error_stmt"). - Optional(), - field.String("hash"), - field.Strings("partial_hashes"). - Optional(), - field.String("operator_version"), - } -} - -// Annotations of the Revision. -func (Revision) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Annotation{Table: DefaultRevisionSchema}, - } -} diff --git a/cmd/atlas/internal/migrate/ent/ent.go b/cmd/atlas/internal/migrate/ent/ent.go index 994e270c60b..7f5b160ed3c 100644 --- a/cmd/atlas/internal/migrate/ent/ent.go +++ b/cmd/atlas/internal/migrate/ent/ent.go @@ -73,7 +73,7 @@ var ( columnCheck sql.ColumnCheck ) -// columnChecker checks if the column exists in the given table. +// checkColumn checks if the column exists in the given table. func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ diff --git a/cmd/atlas/internal/migrate/ent/revision_query.go b/cmd/atlas/internal/migrate/ent/revision_query.go index 17775c83439..909e71c9471 100644 --- a/cmd/atlas/internal/migrate/ent/revision_query.go +++ b/cmd/atlas/internal/migrate/ent/revision_query.go @@ -14,6 +14,7 @@ import ( "ariga.io/atlas/cmd/atlas/internal/migrate/ent/internal" "ariga.io/atlas/cmd/atlas/internal/migrate/ent/predicate" "ariga.io/atlas/cmd/atlas/internal/migrate/ent/revision" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -65,7 +66,7 @@ func (rq *RevisionQuery) Order(o ...revision.OrderOption) *RevisionQuery { // First returns the first Revision entity from the query. // Returns a *NotFoundError when no Revision was found. func (rq *RevisionQuery) First(ctx context.Context) (*Revision, error) { - nodes, err := rq.Limit(1).All(setContextOp(ctx, rq.ctx, "First")) + nodes, err := rq.Limit(1).All(setContextOp(ctx, rq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -88,7 +89,7 @@ func (rq *RevisionQuery) FirstX(ctx context.Context) *Revision { // Returns a *NotFoundError when no Revision ID was found. func (rq *RevisionQuery) FirstID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = rq.Limit(1).IDs(setContextOp(ctx, rq.ctx, "FirstID")); err != nil { + if ids, err = rq.Limit(1).IDs(setContextOp(ctx, rq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -111,7 +112,7 @@ func (rq *RevisionQuery) FirstIDX(ctx context.Context) string { // Returns a *NotSingularError when more than one Revision entity is found. // Returns a *NotFoundError when no Revision entities are found. func (rq *RevisionQuery) Only(ctx context.Context) (*Revision, error) { - nodes, err := rq.Limit(2).All(setContextOp(ctx, rq.ctx, "Only")) + nodes, err := rq.Limit(2).All(setContextOp(ctx, rq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -139,7 +140,7 @@ func (rq *RevisionQuery) OnlyX(ctx context.Context) *Revision { // Returns a *NotFoundError when no entities are found. func (rq *RevisionQuery) OnlyID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = rq.Limit(2).IDs(setContextOp(ctx, rq.ctx, "OnlyID")); err != nil { + if ids, err = rq.Limit(2).IDs(setContextOp(ctx, rq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -164,7 +165,7 @@ func (rq *RevisionQuery) OnlyIDX(ctx context.Context) string { // All executes the query and returns a list of Revisions. func (rq *RevisionQuery) All(ctx context.Context) ([]*Revision, error) { - ctx = setContextOp(ctx, rq.ctx, "All") + ctx = setContextOp(ctx, rq.ctx, ent.OpQueryAll) if err := rq.prepareQuery(ctx); err != nil { return nil, err } @@ -186,7 +187,7 @@ func (rq *RevisionQuery) IDs(ctx context.Context) (ids []string, err error) { if rq.ctx.Unique == nil && rq.path != nil { rq.Unique(true) } - ctx = setContextOp(ctx, rq.ctx, "IDs") + ctx = setContextOp(ctx, rq.ctx, ent.OpQueryIDs) if err = rq.Select(revision.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -204,7 +205,7 @@ func (rq *RevisionQuery) IDsX(ctx context.Context) []string { // Count returns the count of the given query. func (rq *RevisionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, rq.ctx, "Count") + ctx = setContextOp(ctx, rq.ctx, ent.OpQueryCount) if err := rq.prepareQuery(ctx); err != nil { return 0, err } @@ -222,7 +223,7 @@ func (rq *RevisionQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (rq *RevisionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, rq.ctx, "Exist") + ctx = setContextOp(ctx, rq.ctx, ent.OpQueryExist) switch _, err := rq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -461,7 +462,7 @@ func (rgb *RevisionGroupBy) Aggregate(fns ...AggregateFunc) *RevisionGroupBy { // Scan applies the selector query and scans the result into the given value. func (rgb *RevisionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, rgb.build.ctx, ent.OpQueryGroupBy) if err := rgb.build.prepareQuery(ctx); err != nil { return err } @@ -509,7 +510,7 @@ func (rs *RevisionSelect) Aggregate(fns ...AggregateFunc) *RevisionSelect { // Scan applies the selector query and scans the result into the given value. func (rs *RevisionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rs.ctx, "Select") + ctx = setContextOp(ctx, rs.ctx, ent.OpQuerySelect) if err := rs.prepareQuery(ctx); err != nil { return err } diff --git a/cmd/atlas/internal/migrate/ent/runtime/runtime.go b/cmd/atlas/internal/migrate/ent/runtime/runtime.go index 729cd6709de..18dea679b0d 100644 --- a/cmd/atlas/internal/migrate/ent/runtime/runtime.go +++ b/cmd/atlas/internal/migrate/ent/runtime/runtime.go @@ -9,6 +9,6 @@ package runtime // The schema-stitching logic is generated in ariga.io/atlas/cmd/atlas/internal/migrate/ent/runtime.go const ( - Version = "v0.13.0" // Version of ent codegen. - Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. + Version = "v0.13.2-0.20240728160047-15bebe8d8920" // Version of ent codegen. + Sum = "h1:nbro7OIsADbHVgau1PWC19QCZNDyin5pMOJabt0kWcs=" // Sum of ent codegen. )