Code Monkey home page Code Monkey logo

Comments (5)

hsluoyz avatar hsluoyz commented on August 19, 2024

Currently Xorm will automatically name the table after the struct being stored. based on Xorm docs. The struct is:

type CasbinRule struct {
	PType string `xorm:"varchar(100)"`
	V0    string `xorm:"varchar(100)"`
	V1    string `xorm:"varchar(100)"`
	V2    string `xorm:"varchar(100)"`
	V3    string `xorm:"varchar(100)"`
	V4    string `xorm:"varchar(100)"`
	V5    string `xorm:"varchar(100)"`
}

So the default table name would be casbin_rule. And the table would be just as the struct definition. So basically you can't reuse an existing table that has other structures. Would you tell me why you want to rename the table name?

from xorm-adapter.

julisch94 avatar julisch94 commented on August 19, 2024

I was wondering if there's a way to reconfigure the names of the tables and its columns. I saw the struct you've posted already in the code but found no way to change it.

So I can't change the used database name. That's alright for me.
Does that mean that I can't change the column names in casbin_rule (p_type, v1, etc.) either?

from xorm-adapter.

hsluoyz avatar hsluoyz commented on August 19, 2024

I can't change the used database name.

I don't understand. The DB for SQLite is the .db file, which is controlled by you.

Does that mean that I can't change the column names in casbin_rule (p_type, v1, etc.) either?

I think the simplest and most direct way to do it is renaming the struct CasbinRule and its members. Then the table and column names will change at the same time. You can do this job within a IDE, so all references will change too.

from xorm-adapter.

julisch94 avatar julisch94 commented on August 19, 2024

Thank you very much. I will try that.

from xorm-adapter.

julisch94 avatar julisch94 commented on August 19, 2024

By the way, it worked. Renaming the struct CasbinRule and its members makes the created table and its columns be named accordingly.

from xorm-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.