Fiameta Avram
Fiameta Avram

Reputation: 15

Symfony 1.4 doctrine create table

Can someone show me an example on how to use the createTable in Doctrine? For example, I'd like to create a table 'attachment' with the following columns: 'file_path' =>string 'message_id'=>integer

Thanks

Upvotes: 0

Views: 138

Answers (1)

Fiameta Avram
Fiameta Avram

Reputation: 15

Found it :

$this->createTable('attachment', array(
        'id' =>
            array(
                'type' => 'integer',
                'length' => 8,
                'autoincrement' => true,
                'primary' => true,
            ),
        'file_path' =>
            array(
                'type' => 'string',
                'notnull' => true,
                'length' => 255,
            ),
        'message_id' =>
            array(
                'type' => 'integer',
                'notnull' => false,
                'length' => 8,
            ),
        'created_at' =>
            array(
                'notnull' => true,
                'type' => 'timestamp',
                'length' => 25,
            ),
        'updated_at' =>
            array(
                'notnull' => true,
                'type' => 'timestamp',
                'length' => 25,
            ),
    ), array(
        'indexes' =>
            array(
            ),
        'primary' =>
            array(
                0 => 'id',
            ),
        'collate' => 'utf8_general_ci',
        'charset' => 'utf8',
    ));

Upvotes: 1

Related Questions