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

Error while creating new adpator #67

Open
VaishnavcveeZ opened this issue Aug 26, 2024 · 1 comment
Open

Error while creating new adpator #67

VaishnavcveeZ opened this issue Aug 26, 2024 · 1 comment
Assignees
Labels

Comments

@VaishnavcveeZ
Copy link

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.
@hsluoyz
Copy link
Member

hsluoyz commented Aug 27, 2024

@VaishnavcveeZ can you make a PR?

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

No branches or pull requests

4 participants
@hsluoyz @VaishnavcveeZ @casbin-bot and others