func (pg *PostgreSQL) CreateOrUpdateDomain(projectName string, domain models.Domain) error {
	d := pgDomain{}
	d.FromModel(domain)
	err := pg.createOrUpdateDomain(projectName, d)
	if err != nil {
		return err
	}
	return nil
}
CreateOrUpdateDomain is the "public" handler for creating a new or updating a domain name.
It is the same function for subdomains as they are handled in the exact same manner.
package postgresql
import (
	"errors"
	"github.com/netm4ul/netm4ul/core/events"
	"github.com/netm4ul/netm4ul/core/database/models"
	log "github.com/sirupsen/logrus"
)
func (pg *PostgreSQL) createOrUpdateDomain(projectName string, domain pgDomain) error {
	project := pgProject{}
	res := pg.db.Where("name = ?", projectName).First(&project)
	if res.Error != nil {
		return errors.New("Could not find assiociated projet : " + res.Error.Error())
	}
	log.Debugf("Project with name : %s : %+v", projectName, project)
	domain.Project = project
	log.Debugf("Saving domain : %+v", domain)
	res = pg.db.Where("project_id = ?", project.ID).Where("name = ?", domain.Name).FirstOrCreate(&domain)
	if res.Error != nil {
		return errors.New("Could not save or update domain : " + res.Error.Error())
	}
	return nil
}