# Overload Migration seed template

**URL:** <https://discourse.cakephp.org/t/overload-migration-seed-template/3667>\
**Category:** Need Help\
**Created:** [December 18, 2017, 12:54pm UTC](https://discourse.cakephp.org/t/overload-migration-seed-template/3667 "2017-12-18T12:54:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mistermasque](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Mistermasque](https://discourse.cakephp.org/u/Mistermasque)\
**Post date:** [December 18, 2017, 12:55pm UTC](https://discourse.cakephp.org/t/overload-migration-seed-template/3667/1 "2017-12-18T12:55:00Z")

</div>

Hi,

I tried to overload the bake template for seed migration command.  
My objective is to obtain this :

```
<?php
        use Migrations\AbstractSeed;

        /**
         * Table seed.
         */
        class TableSeed extends AbstractSeed
        {
            /**
             * Run Method.
            ...
             */
            public function run()
            {
                $data = [
                    table data
                ];

                $table = $this->table('table');
                $this->execute('SET foreign_key_checks=0');
                $this->execute('TRUNCATE TABLE ' . $table->getName());
                $table->insert($data)->save();
                $this->execute('SET foreign_key_checks=1');
            }
        }
```

Instead of the actual template :

```
<?php
    use Migrations\AbstractSeed;

    /**
     * Table seed.
     */
    class TableSeed extends AbstractSeed
    {
        /**
         * Run Method.
         ...
         */
        public function run()
        {
            $data = [
                table data
            ];

            $table = $this->table('table');
            $table->insert($data)->save();
        }
    }
```

I follow the documentation [here](https://book.cakephp.org/3.0/en/bake/development.html#customizing-the-bake-templates)

So I copied the seed.ctp file into my App/src/Template/Bake/Seed/ folder.  
I modified it to this :

```
<%
    /**
     [License]
     */
    %>
    <?php
    use Migrations\AbstractSeed;

    /**
     * <%= $name %> seed.
     */
    class <%= $name %>Seed extends AbstractSeed
    {
        /**
         * Run Method.
         ...
         */
        public function run()
        {
    <% if ($records): %>
            $data = <%= $records %>;
    <% else: %>
            $data = [];
    <% endif; %>
            
            $table = $this->table('<%= $table %>');
            $this->execute('SET foreign_key_checks=0');
            $this->execute('TRUNCATE TABLE ' . $table->getName());
            $table->insert($data)->save();
            $this->execute('SET foreign_key_checks=1');
        }
    }
```

But the command bin\cake bake seed --data Table  
doesn’t change anything, I obtain the default file.

So I create a plugin named Test with Bake.  
I put my file seed.ctp into the folder plugins/Test/src/Template/Bake/Seed/

But the command bin\cake bake seed --data --theme Test Table  
doesn’t change anything too.

Am I doing something wrong ?  
I tried to read the bake code but I clearly don’t understand how the bake template works.

I am using cakephp v3.3.15

Thanks for your help.
