TableGeneratorSchemaVisitor.php 1.5 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\DBAL\Id;

Benjamin Morel's avatar
Benjamin Morel committed
5 6 7
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
8 9 10 11
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Visitor\Visitor;
12

13
class TableGeneratorSchemaVisitor implements Visitor
14
{
15
    /** @var string */
16 17
    private $generatorTableName;

Benjamin Morel's avatar
Benjamin Morel committed
18 19 20
    /**
     * @param string $generatorTableName
     */
21 22 23 24 25 26
    public function __construct($generatorTableName = 'sequences')
    {
        $this->generatorTableName = $generatorTableName;
    }

    /**
Benjamin Morel's avatar
Benjamin Morel committed
27
     * {@inheritdoc}
28 29 30 31 32
     */
    public function acceptSchema(Schema $schema)
    {
        $table = $schema->createTable($this->generatorTableName);
        $table->addColumn('sequence_name', 'string');
33 34
        $table->addColumn('sequence_value', 'integer', ['default' => 1]);
        $table->addColumn('sequence_increment_by', 'integer', ['default' => 1]);
35 36 37
    }

    /**
Benjamin Morel's avatar
Benjamin Morel committed
38
     * {@inheritdoc}
39 40 41 42 43 44
     */
    public function acceptTable(Table $table)
    {
    }

    /**
Benjamin Morel's avatar
Benjamin Morel committed
45
     * {@inheritdoc}
46 47 48 49 50 51
     */
    public function acceptColumn(Table $table, Column $column)
    {
    }

    /**
Benjamin Morel's avatar
Benjamin Morel committed
52
     * {@inheritdoc}
53 54 55 56 57 58
     */
    public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
    {
    }

    /**
Benjamin Morel's avatar
Benjamin Morel committed
59
     * {@inheritdoc}
60 61 62 63 64 65
     */
    public function acceptIndex(Table $table, Index $index)
    {
    }

    /**
Benjamin Morel's avatar
Benjamin Morel committed
66
     * {@inheritdoc}
67 68 69 70 71
     */
    public function acceptSequence(Sequence $sequence)
    {
    }
}