Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New create index check breaks migration generation for Atlas #291

Open
mathieu-lemay opened this issue Nov 22, 2024 · 0 comments
Open

New create index check breaks migration generation for Atlas #291

mathieu-lemay opened this issue Nov 22, 2024 · 0 comments
Assignees

Comments

@mathieu-lemay
Copy link

GORM Playground Link

go-gorm/playground#774

Description

Since PR #285, the migration generation for Atlas fails. This is likely due to the generation using a mock database that doesn't really have the index.
Since that change, I get some failed to create index ... errors

How to reproduce

This sample program shows the issue. With go-gorm/[email protected], it works fine, but it fails with go-gorm/[email protected].

package main

import (
        "io"
        "log"
        "os"

        "ariga.io/atlas-provider-gorm/gormschema"

        "gorm.io/gorm"
)

type Product struct {
  gorm.Model

  Code  string
  Price uint
}

func main() {
        stmts, err := gormschema.New("postgres").Load(&Product{})

        if err != nil {
                log.Fatalf("error loading gorm schema: %v\n", err)
        }

        _, err = io.WriteString(os.Stdout, stmts)

        if err != nil {
                log.Fatalf("error writing statements to stdout: %v\n", err)
        }
}

Expected behavior: It should output a SQL script to create the Products table
Actual behavior: It fails with error loading gorm schema: failed to create index with name idx_products_deleted_at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants