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

provider is not creating foreign key constrains for postgres #3

Open
fahadnaeemkhan opened this issue Oct 25, 2024 · 2 comments
Open
Assignees

Comments

@fahadnaeemkhan
Copy link

fahadnaeemkhan commented Oct 25, 2024

ORM/Models

package models

import (
	"time"
)

type Vnf struct {
	Id             int64     `orm:"auto;pk"                      form:"-"`
	ServiceId      string    `orm:"unique;index"                 form:"-"`
	Type           string    `orm:"null,index"                   form:"type,select"    required:"true" class:"w-full  border-b-2 border-gray-300 focus:border-blue-300 outline-none"`
	Version        string    `                                   form:"version,select" required:"true" class:"w-full  border-b-2 border-gray-300 focus:border-blue-300 outline-none"`
	Flavor         string    `                                   form:"flavor,select"  required:"true" class:"w-full  border-b-2 border-gray-300 focus:border-blue-300 outline-none"`
	NoOfInterfaces int       `                                   form:"-" required:"true" class:"w-full  border-b-2 border-gray-300 focus:border-blue-300 outline-none"`
	Status         string    `orm:""                             form:"-"`
	Created        time.Time `orm:"auto_now_add;type(datetime)"`
	Updated        time.Time `orm:"auto_now;type(datetime)"`

	// relations
	Interfaces   []*VnfInterface  `orm:"reverse(many)"`
	WanInterface *VnfWanInterface `orm:"reverse(one)"`
	PublicIp     *VnfPublicIp     `orm:"reverse(one)"`
}

type VnfInterface struct {
	Id          int64 `orm:"auto;pk"`
	InterfaceId int   `orm:"index"`

	// relations
	Vnf              *Vnf              `orm:"rel(fk)"`
	VnfVxlanVlanPair *VnfVxlanVlanPair `orm:"rel(one)"`
}

type VnfVxlanVlanPair struct {
	Id    int64 `orm:"auto;pk"`
	Vxlan int   `orm:"unique;index"`
	Vlan  int   `orm:"unique;index"`

	// relations
	VnfInterface *VnfInterface `orm:"null;reverse(one);rel(fk);on_delete(set_null)"`
}

type VnfWanInterface struct {
	Id          int64 `orm:"auto;pk"`
	InterfaceId int   `orm:"index"`

	// relations
	Vnf         *Vnf         `orm:"null;rel(one);on_delete(set_null)]"`
	VnfWanVxlan *VnfWanVxlan `orm:"rel(one)"`
}

type VnfWanVxlan struct {
	Id    int64 `orm:"auto;pk"`
	Vxlan int   `orm:"unique;index"`

	// relations
	VnfWanInterface *VnfWanInterface `orm:"null;reverse(one);rel(one);on_delete(set_null)"`
}

type VnfPublicIp struct {
	Id        int64  `orm:"auto;pk"`
	IpAddress string `orm:"unique " valid:"IP"`

	// relations
	Vnf *Vnf `orm:"null;rel(one);on_delete(set_null)"`
}

ERD

Screenshot 2024-10-24 at 10 50 04 PM
@fahadnaeemkhan fahadnaeemkhan changed the title provider is not create foreign key constrains provider is not create foreign key constrains for postgres Oct 25, 2024
@fahadnaeemkhan
Copy link
Author

This can be seen in the example posted at Atlas guide for beego orm too. https://atlasgo.io/guides/orms/beego

@giautm
Copy link
Member

giautm commented Oct 25, 2024

Hello, I'll check the issue and update you soon.

@fahadnaeemkhan fahadnaeemkhan changed the title provider is not create foreign key constrains for postgres provider is not creating foreign key constrains for postgres Oct 26, 2024
@giautm giautm self-assigned this Nov 4, 2024
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