Skip to content

Error while creating new adpator #67

@VaishnavcveeZ

Description

@VaishnavcveeZ

Gettting error while running application code for creating adaptor. The error will happen at the 2nd time.

Error -
pq: relation "IDX_casbin_rule_ptype" already exists"

Steps-
1 . Create table for casbin

CREATE TABLE IF NOT EXISTS "casbin_rule" (
    "id" VARCHAR(100) NOT NULL  PRIMARY KEY DEFAULT gen_random_uuid(),
    "ptype" VARCHAR(100) NOT NULL ,
    "v0" VARCHAR(100) NOT NULL,
    "v1" VARCHAR(100) NOT NULL,
    "v2" VARCHAR(100) NOT NULL,
    "v3" VARCHAR(100) NOT NULL,
    "v4" VARCHAR(100),
    "v5" VARCHAR(100)
);
  1. Run application with adaptor code
dsn := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s search_path=%s timezone=%s sslmode=disable",
		Host,
		Port,
		User,
		Password,
		DbName,
		Schema,
		Timezone)

xormAdaptor, err := xormadapter.NewAdapter("postgres", dsn, true)
	if err != nil {
		slog.Error("xormadapter.NewAdapter",
			"err", err)
		return err
	}
  1. Run the application first time will create an index for colum "ptype" - IDX_casbin_rule_ptype. While running 2nd time will get an error for the existing index.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions