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

check if table exists ? #2

Closed
joeblew99 opened this issue Sep 11, 2017 · 1 comment
Closed

check if table exists ? #2

joeblew99 opened this issue Sep 11, 2017 · 1 comment

Comments

@joeblew99
Copy link

joeblew99 commented Sep 11, 2017

Just trying this out.. Its pretty nice..
i dont think the generated code checks if the Table exists ?

What do you think about the idea of being able to generate the check and for all functions to call it ?
It would be a flag on the generator, so you dont have to use it.

Its very nice at Development time to more fast.

--

It brings uo the whole question of migrations of course too....

@jirfag
Copy link
Owner

jirfag commented Sep 12, 2017

Hello!

  1. What to do if we've found, that table doesnt exist? Return special error? Panic? Something else?
    I suggest next autogenerated tables manager for struct User:
type UserTableManager struct {
  db *gorm.DB
}

func NewUserTableManager(db *gorm.DB)UserTableManager  {}

func (m UserTableManager) CreateTable() error {}
func (m UserTableManager) DropTable() error {}
func (m UserTableManager) AddColumn(...) error {}
func (m UserTableManager) DropColumn(...) error {}
// etc
  1. I can support automigrations with this tables manager:
func (m UserTableManager) AutoMigrate() error {}

What do you think about that?

@jirfag jirfag closed this as completed Oct 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants