xorm-adapter icon indicating copy to clipboard operation
xorm-adapter copied to clipboard

Error while creating new adpator

Open VaishnavcveeZ opened this issue 1 year ago • 1 comments

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.

VaishnavcveeZ avatar Aug 26 '24 19:08 VaishnavcveeZ