Can't access collection admin page after detach / reattach-TFS 2015 - tfs

I have 2 instances of TFS which are A & B
A consists of 3 collections and B consists of 1 collection.
I recently moved 1 collection from B ===> A instance.
After that I am getting the following error while accessing the admin page.
VS402375: Can't find the process associated with team project '76916fec-d89d-43cd-a2f6-89cf83d8100f'. Contact support to resolve this error.
When i checked the Project ID & Values for 3 collections, They look same but for the fourth collection(which was moved from B==>A) which is different.
If I go ahead and update the values(process template id) for the project_id's, The issue will be resolved or not?
can you let me know.
PFA https://social.msdn.microsoft.com/Forums/silverlight/en-US/a31160d4-0bca-4d94-8444-6cd0f4f01da4/cant-access-collection-admin-page-after-detach-reattach?forum=tfsgeneral

Firstly make sure that you exactly follow the instructions on Move a team project collection.
Base on the thread you mentioned and your description, the problem should be that the default process templates in tfs_configuration of the new install had IDs that didn't match the projects in the new collection.
So, you can try to backup the DBs first.
Then try to update the corresponding CurrentProcessTemplateId for the moved team project to match the ID retrieved from tfs_configuration, that means update the table: [Tfs_DefaultCollection].[dbo].[tbl_project_properties]. As update the tfs_configuration may cause problems for other three collections.
e.g.:
update [Tfs_DefaultCollection].[dbo].[tbl_project_properties] set value = 'the template ID retrieved from A' where Name = 'CurrentProcessTemplateId' and project_id = 'your team project id'
If that still not work, just try to also update the OriginalProcessTemplateId
update [Tfs_DefaultCollection].[dbo].[tbl_project_properties] set value = 'the template ID retrieved from A' where Name = 'OriginalProcessTemplateId' and project_id = 'your team project id'

delete from table [Tfs_DefaultCollection].[dbo].[tbl_project_properties] where name = 'CurrentProcessTemplateId' and project_id=''
delete from table [Tfs_DefaultCollection].[dbo].[tbl_project_properties] where name = 'OriginalProcessTemplateId' and project_id=''
delete from table [Tfs_DefaultCollection].[dbo].[tbl_project_properties] where name = 'ProcessTemplateType' and project_id=''
Running above commands helped me.

Related

Restoring / deleting soft deleted items

I am using Python Eve with the soft_delete enabled for some resources of my REST backend and I meet a problem to really delete from the Mongo DB a soft deleted item.
My application workflow involves:
- creating an item: POST /item with unique name
- deleting an item: DELETE /item
- creating an item: POST /item with the same unique name
On the third step, the item is still existing in the DB but it is _deleted: True. How should I restore this item when the user POST /item ?
I know that a PUT /item or PATCH /item will do the trick but my user do not know that he must PUT/PATCH rather than POSTing ...
I tried to use the deleteitem_internal function inside an on_pre_POST_... hook function but it raises a 404 error.
I suppose that I should patch_internal my item with the POSTed data and then abort the request. Is this solution the best one to implement when one wants to restore a soft deleted item ?

After destroying all records why are new objects being created with an id higher than the old last record's id?

Hi I have a seeds file in my rails app where I destroy all the old objects to start, and then create an assortment of new objects. I would expect the new objects to be created with an id of 1 since all the old objects were destroyed, but new objects are being created with ids that are higher than all of the ids of the old objects. So for an example I had 50 Post objects all with an id of 1-50. I run Post.destroy_all and created 50 more Post objects. All the old Post objects are destroyed, but the new Post objects all have an id of 51-100. Post.find(1) does not exist.
Here is my seeds file:
Photo.destroy_all
Post.destroy_all
Like.destroy_all
50.times do
Photo.create(name: Faker::Name.name)
end
50.times do
Post.create(body: Faker::Lorem.paragraph)
end
def get_parent
resource = [Post, Photo].sample
parent = resource.all.sample
parent
end
150.times do
parent = get_parent
Like.create(likeable_type: parent.class.name, likeable_id: parent.id)
end
If I run rake db:seed multiple times the ids of each collection of objects gets 50 higher every run. So when the ids are 101 - 150 and I run rake db:seed and the ids are now 151-200 with no objects existing with an id less than 151.
How do I create objects with ids starting at 1 after all records have been destroyed, and why am I getting this current behavior?
Thanks for the help.
You should write this in seed file after destroy command line:
ActiveRecord::Base.connection.reset_pk_sequence!('photos')
just run rake db:reset and it should reset everything and re-seed the DB back at 0.
That will address getting the records back at 0, but as to why it's doing that, it's because that's the way that it's designed when you're deleting the data it is simply removing the data and not deleting it's place in the DB which it should do generally. That behavior generally is a good thing.
Imagine if you had a user w/ an ID of 2 that gets deleted or deletes their account and you have user 1 and 3 as well. You wouldn't necessarily want to re-use that ID: 2 for your next user but would rather give them a new unique id for a number of reasons. Perhaps their user ID is tied to records elsewhere in the DB, for security purposes etc. I hope this helps!
It is the sequence in your DB, try to reset the sequence after deleting your records by:
ALTER SEQUENCE photos_id_seq RESTART WITH 1;

Can't view newly created records after database sequence reset

So I had some problems with my database. I have an import functionality which I used to import a few thousand records. Now I was developing locally (SQLite) and everything worked fine. I pushed my updates to heroku where I have a PostgreSQL database. I ran my import there and it appeared to work well too. Now, I'm trying to manually create an other record in that table and I kept getting the error that the unique ID was a duplicate. So, after some online searching I created this extension to active record:
def self.reset_pk_sequence
case ActiveRecord::Base.connection.adapter_name
when 'SQLite'
new_max = maximum(primary_key) || 0
update_seq_sql = "update sqlite_sequence set seq = #{new_max} where name = '#{table_name}';"
ActiveRecord::Base.connection.execute(update_seq_sql)
when 'PostgreSQL'
ActiveRecord::Base.connection.reset_pk_sequence!(table_name)
else
raise "Task not implemented for this DB adapter"
end
end
I ran it on my table, and the ID is now counting up from where it should (3000 something instead of 1,2,3, etc).
My problem now is that I am able to create new records in my table, and I see them in my index page. However, when I try to open that specific record, I get this error:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
The link from my index is just to the ID of the record. When I check if this ID exists in the console, I'm perfectly able to find the record. What's going wrong here?
I figured it out. I had some empty associations that I was trying to display in the view. The error threw me off since it appeared like something was wrong with my record.

Programmatically generated Spree Taxons not showing tree in Admin

I am trying to generate a Spree Commerce taxonomy programmatically within a Ruby script (a la seeds.rb). In the customer-facing product pages the Taxons appear, but they do not work from the Admin pages.
The "tree" view of the Taxonomy shows the root node, but no children
On the product edit page, I cannot add any of my Taxons
Here's an example:
taxonomy_stones = Spree::Taxonomy.where(:name => 'Gemstone Type').first_or_create
tax_stones = Spree::Taxon.where(name: "Gemstone", parent: nil, taxonomy: taxonomy_stones).first_or_create
tax_diamond = Spree::Taxon.where(name: "Diamond", parent: tax_stones, taxonomy: taxonomy_stones).first_or_create
tax_fancy_yellow = Spree::Taxon.where(name: "Fancy Yellow Diamond", parent: tax_diamond, taxonomy: taxonomy_stones).first_or_create
tax_fancy_pink = Spree::Taxon.where(name: "Fancy Pink Diamond", parent: tax_diamond, taxonomy: taxonomy_stones).first_or_create
When I run this, entries appear in the database for my Taxonomy and Taxons. I am able to programmatically associate Products to the Taxons:
product_BL212.taxons << tax_diamond
I'm guessing that my Taxon-creation code is incomplete or incorrect in some way, but I am not sure how. Can anyone who is more familiar with Spree's internals provide an example of doing this correctly?
Further Observations
I used the Admin UI to create sample Taxonomies and have compared the database entries to my generated ones. The name and permalink fields in spree_taxons are blank for my generated Taxons, but not the Spree-created ones. When I manually populated some of the values for the root node and two sample children, the taxonomy/taxons still don't work correctly in Admin.
Is it important to have these values populated in spree_taxons when spree_taxons_translations has the needed information?
If so, how do I get Spree to populate the values for these fields correctly?
Calling Spree::Taxon.rebuild! after adding the Taxons resolves the issue.
I had a similar issue where I had the code
Spree::Taxonomy.find_or_create_by(name:'Brands')
Spree::Taxon.find_or_initialize_by(name:'brand_name').update(taxonomy: Spree::Taxonomy.find_by(name:'Brands'))
Running Spree::Taxon.rebuild! did not solve the issue. I found out that creating a Taxonomy also creates a Taxon with it and I had to use the ID for the associated taxon in the parent column for the new taxon I was creating.
So
Spree::Taxon.find_or_initialize_by(name:'brand_name').update(taxonomy: Spree::Taxonomy.find_by(name:'Brands'))
had to be changed to
Spree::Taxon.find_or_initialize_by(name:'brand_name').update(taxonomy: Spree::Taxonomy.find_by(name:'Brands'), parent: Spree::Taxon.find_by(name:'Brands'))
The Taxon.parent attribute expects a root object.
For example:
t = Spree::Taxonomy.create(name: "Season")
tt = Spree::Taxon.create(name: "Winter", taxonomy: t, parent: t.root)

How to write tfs work item query for fetching workitems which are under more than one iteration path

I want to write a tfs work item query like below
(Team project = #Project)
AND (Assigned to = user1 OR Assigned to = user2 OR Assigned to = user3)
AND (Iteration path under path1 OR Iteration path under parth2)
Please help me in achieving the same.
Below is what i am trying to do, but its not giving me desired results.
I think i found the problem.
The problem was with the first class where i was using Team project = #Project
and #Project was set to one iteration path and hence it was always showing the result from one iteration path.
Removing the first class solved the problem.

Resources