<p>Not the most direct way, but you could do something like this from your plugin's record:</p>

<pre><code>public function createTable()
{
    // Let the base class do the actual work
    parent::createTable();

    // Change the PK auto-increment starting point.
    craft()-&gt;db-&gt;createCommand()-&gt;setText('ALTER TABLE myTable AUTO_INCREMENT=9999')-&gt;execute();

}
</code></pre>

CC BY-SA 3.0
2016-04-26T00:56:47.190Z
2016-04-26T00:56:47.190Z
Brad Bell
<p>Is there a way to define my plugins Record start ID? Now it start with ID 1, and for various reasons I would like to define a starting number.</p>

<plugin-development><records>
Define record start ID
# Define record start ID

(Asked by: username_0 on 2016-04-25)

Is there a way to define my plugins Record start ID? Now it start with ID 1, and for various reasons I would like to define a starting number.

**Tags:** plugin-development, records

---

## 1 answers

### Answer by username_1 on 2016-04-26. Score: 2 | Accepted answer

Not the most direct way, but you could do something like this from your plugin's record:
public function createTable()
{
    // Let the base class do the actual work
    parent::createTable();

    // Change the PK auto-increment starting point.
    craft()->db->createCommand()->setText('ALTER TABLE myTable AUTO_INCREMENT=9999')->execute();

}


---

