// create saves a new entity in the database.
create saves a new entity in the database.
// create saves a new entity in the database .
func (r MigrationRepository) create(ctx context.Context, tx *sqlx.Tx, entity *migration.Log) error {
	var lastInsertID uint
	err := tx.QueryRowContext(ctx, `
			INSERT INTO ` + migration.TableName + ` (id, status, "name", "time") 
			VALUES ($1, $2, $3, Now()) RETURNING id
		`, entity.ID, entity.Status, entity.Name).Scan(&lastInsertID)
	if err != nil {
		return errors.Wrapf(err, "MigrationRepository: error inserting entity %v", entity)
	}
	newEntity, err := r.get(ctx, tx, lastInsertID)
	if err != nil {
		return errors.Wrapf(err, "MigrationRepository: error inserting entity %v", entity)
	}
	*entity = *newEntity
	return nil
}
func ( r MigrationRepository ) create ( ctx context . Context , tx * sqlx . Tx , entity * migration . Log ) error { var lastInsertID uint err := tx . QueryRowContext ( ctx , `
			INSERT INTO ` + migration . TableName + ` (id, status, "name", "time") 
			VALUES ($1, $2, $3, Now()) RETURNING id
		` , entity . ID , entity . Status , entity . Name ) . Scan ( & lastInsertID ) if err != nil { return errors . Wrapf ( err , " " , entity ) } newEntity , err := r . get ( ctx , tx , lastInsertID ) if err != nil { return errors . Wrapf ( err , " " , entity ) } * entity = * newEntity return nil }
create saves a new entity in the database.
create saves a new entity in the database .