I am using PublishManager.PublishSmart
to auto publish items from master db to web db.
New items which are in final workflow state are getting published as expected but for the existing items if I make the changes and reset the workflow state other than final, after auto publish runs this existing item gets deleted from web db.
Here is my code
Database master = Database.GetDatabase("master");
Database targetDB = Factory.GetDatabase("web");
// passing the rootItemID GUID here
var rootItem = master.GetItem(new ID(rootItemID));
Database[] targets = new Database[1] { targetDB };
Language[] array = rootItem.Languages;
PublishManager.PublishSmart(rootItem.Database, targets, array);