Skip to content

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

@MrSpoony

Description

@MrSpoony

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions