# Automatic creation of scripts

**URL:** <https://forums.toadworld.com/t/automatic-creation-of-scripts/1877>\
**Category:** Toad Data Modeler\
**Created:** [February 3, 2009, 6:40am UTC](https://forums.toadworld.com/t/automatic-creation-of-scripts/1877 "2009-02-03T06:40:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chenrystreamwide.com](https://avatars.discourse-cdn.com/v4/letter/c/e99b99/32.png) [@chenrystreamwide.com](https://forums.toadworld.com/u/chenrystreamwide.com)\
**Post date:** [February 3, 2009, 6:40am UTC](https://forums.toadworld.com/t/automatic-creation-of-scripts/1877/1 "2009-02-03T06:40:21Z")

</div>

Hi everybody,

I am currently trying to make a script to create an index for every single primary key present in a physical model. Obviously, I wish every index to have the same columns as the matching primary key.

But all I have been able to come up with until now is a script creating empty indexes. I miss the code piece adding the index columns. Can anyone help ?

Create\_Primary\_Key\_Indexes.js (1.84 KB)

---

<div class="post-metadata">

**Author:** ![Vaclav\_Frolik](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/vaclav_frolik/32/12_2.png) [@Vaclav\_Frolik](https://forums.toadworld.com/u/Vaclav_Frolik)\
**Post date:** [February 3, 2009, 9:11am UTC](https://forums.toadworld.com/t/automatic-creation-of-scripts/1877/2 "2009-02-03T09:11:00Z")

</div>

**NewIndexItem.Name = CurrentKeyItem.Name;**  
Regards,

Vaclav & Mario.

Hi,

modify the AddIndexForKey function and write this:  
**NewIndexItem.Attribute = CurrentKeyItem.Attribute;**  
instead of:
