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

GORM with Postgres: 'information_schema' does not exist #97

Open
MrSpoony opened this issue Nov 1, 2023 · 4 comments
Open

GORM with Postgres: 'information_schema' does not exist #97

MrSpoony opened this issue Nov 1, 2023 · 4 comments

Comments

@MrSpoony
Copy link

MrSpoony commented Nov 1, 2023

I tried to use the example in the readme to create a gorm database:

minimal example:

package main

import (
	"database/sql"
	"log"

	_ "github.com/proullon/ramsql/driver"

	"gorm.io/driver/postgres"
	"gorm.io/gorm"
)

type Product struct {
	gorm.Model
}

// From the example in the readme
func main() {
	ramdb, err := sql.Open("ramsql", "TestGormQuickStart")
	if err != nil {
		log.Fatal(err)
	}
	db, err := gorm.Open(postgres.New(postgres.Config{Conn: ramdb}), &gorm.Config{})
	if err != nil {
		log.Fatal(err)
	}

	// Migrate the schema
	err = db.AutoMigrate(&Product{})
	if err != nil {
		log.Fatal(err)
	}
}

When I try to run this I get the following error:
schema 'information_schema' does not exist
[0.160ms] [rows:-] SELECT count(*) FROM information_schema.tables WHERE table_schema = CURRENT_SCHEMA() AND table_name = 'products' AND table_type = 'BASE TABLE'

@Mcklmo
Copy link

Mcklmo commented Dec 15, 2023

I'm getting the same error. Please fix!

@tbnguyen1407
Copy link

Any update on this issue?

@proullon
Copy link
Owner

proullon commented Sep 7, 2024

I didn't work on this issue for a while, it requires to emulate Postgres's information_schema table, which is doable I guess but it feels like a rabbit hole, I don't want to rewrite Postgres.

That said, if it's blocking for a lot of use case, maybe it's worth it. I'll take a look again

@Mcklmo
Copy link

Mcklmo commented Sep 7, 2024

ramsql would be extremely useful for many projects in my company, if it would work with postgres. Without this, it's unusable for us, unfortunately.
Postgres is also maybe the most popular sql dialect right now, so I think it's a good investment for you.

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

4 participants