Armado de Esquemas YML
Versión 5 (Guillermo Zdanowicz, 02/10/2015 21:41)
| 1 | 1 | Guillermo Zdanowicz | h1. Armado de Esquemas YML |
|---|---|---|---|
| 2 | 1 | Guillermo Zdanowicz | |
| 3 | 1 | Guillermo Zdanowicz | A diferencia de Symfony 1, el esquema es armado por cada clase |
| 4 | 1 | Guillermo Zdanowicz | |
| 5 | 1 | Guillermo Zdanowicz | *Primero creamos la carepta doctrine* |
| 6 | 1 | Guillermo Zdanowicz | |
| 7 | 1 | Guillermo Zdanowicz | mkdir src/JobeetBundle/Resources/config/doctrine |
| 8 | 1 | Guillermo Zdanowicz | |
| 9 | 1 | Guillermo Zdanowicz | Creamos y editamos los archivos de esquemas |
| 10 | 1 | Guillermo Zdanowicz | |
| 11 | 1 | Guillermo Zdanowicz | mcedit src/JobeetBundle/Resources/config/doctrine/Category.orm.yml |
| 12 | 1 | Guillermo Zdanowicz | |
| 13 | 1 | Guillermo Zdanowicz | <pre> |
| 14 | 1 | Guillermo Zdanowicz | # src/JobeetBundle/Resources/config/doctrine/Category.orm.yml |
| 15 | 1 | Guillermo Zdanowicz | JobeetBundle\Entity\Category: |
| 16 | 1 | Guillermo Zdanowicz | type: entity |
| 17 | 1 | Guillermo Zdanowicz | table: category |
| 18 | 1 | Guillermo Zdanowicz | id: |
| 19 | 1 | Guillermo Zdanowicz | id: |
| 20 | 1 | Guillermo Zdanowicz | type: integer |
| 21 | 1 | Guillermo Zdanowicz | generator: { strategy: AUTO } |
| 22 | 1 | Guillermo Zdanowicz | fields: |
| 23 | 1 | Guillermo Zdanowicz | name: |
| 24 | 1 | Guillermo Zdanowicz | type: string |
| 25 | 1 | Guillermo Zdanowicz | length: 255 |
| 26 | 1 | Guillermo Zdanowicz | unique: true |
| 27 | 1 | Guillermo Zdanowicz | oneToMany: |
| 28 | 1 | Guillermo Zdanowicz | jobs: |
| 29 | 1 | Guillermo Zdanowicz | targetEntity: Job |
| 30 | 1 | Guillermo Zdanowicz | mappedBy: category |
| 31 | 1 | Guillermo Zdanowicz | manyToMany: |
| 32 | 1 | Guillermo Zdanowicz | affiliates: |
| 33 | 1 | Guillermo Zdanowicz | targetEntity: Affiliate |
| 34 | 1 | Guillermo Zdanowicz | mappedBy: categories |
| 35 | 1 | Guillermo Zdanowicz | </pre> |
| 36 | 1 | Guillermo Zdanowicz | |
| 37 | 1 | Guillermo Zdanowicz | mcedit src/JobeetBundle/Resources/config/doctrine/Job.orm.yml |
| 38 | 1 | Guillermo Zdanowicz | |
| 39 | 1 | Guillermo Zdanowicz | <pre> |
| 40 | 1 | Guillermo Zdanowicz | # src/JobeetBundle/Resources/config/doctrine/Job.orm.yml |
| 41 | 1 | Guillermo Zdanowicz | JobeetBundle\Entity\Job: |
| 42 | 1 | Guillermo Zdanowicz | type: entity |
| 43 | 1 | Guillermo Zdanowicz | table: job |
| 44 | 1 | Guillermo Zdanowicz | id: |
| 45 | 1 | Guillermo Zdanowicz | id: |
| 46 | 1 | Guillermo Zdanowicz | type: integer |
| 47 | 1 | Guillermo Zdanowicz | generator: { strategy: AUTO } |
| 48 | 1 | Guillermo Zdanowicz | fields: |
| 49 | 1 | Guillermo Zdanowicz | type: |
| 50 | 1 | Guillermo Zdanowicz | type: string |
| 51 | 1 | Guillermo Zdanowicz | length: 255 |
| 52 | 1 | Guillermo Zdanowicz | nullable: true |
| 53 | 1 | Guillermo Zdanowicz | company: |
| 54 | 1 | Guillermo Zdanowicz | type: string |
| 55 | 1 | Guillermo Zdanowicz | length: 255 |
| 56 | 1 | Guillermo Zdanowicz | logo: |
| 57 | 1 | Guillermo Zdanowicz | type: string |
| 58 | 1 | Guillermo Zdanowicz | length: 255 |
| 59 | 1 | Guillermo Zdanowicz | nullable: true |
| 60 | 1 | Guillermo Zdanowicz | url: |
| 61 | 1 | Guillermo Zdanowicz | type: string |
| 62 | 1 | Guillermo Zdanowicz | length: 255 |
| 63 | 1 | Guillermo Zdanowicz | nullable: true |
| 64 | 1 | Guillermo Zdanowicz | position: |
| 65 | 1 | Guillermo Zdanowicz | type: string |
| 66 | 1 | Guillermo Zdanowicz | length: 255 |
| 67 | 1 | Guillermo Zdanowicz | location: |
| 68 | 1 | Guillermo Zdanowicz | type: string |
| 69 | 1 | Guillermo Zdanowicz | length: 255 |
| 70 | 1 | Guillermo Zdanowicz | description: |
| 71 | 1 | Guillermo Zdanowicz | type: text |
| 72 | 1 | Guillermo Zdanowicz | how_to_apply: |
| 73 | 1 | Guillermo Zdanowicz | type: text |
| 74 | 1 | Guillermo Zdanowicz | token: |
| 75 | 1 | Guillermo Zdanowicz | type: string |
| 76 | 1 | Guillermo Zdanowicz | length: 255 |
| 77 | 1 | Guillermo Zdanowicz | unique: true |
| 78 | 1 | Guillermo Zdanowicz | is_public: |
| 79 | 1 | Guillermo Zdanowicz | type: boolean |
| 80 | 1 | Guillermo Zdanowicz | nullable: true |
| 81 | 1 | Guillermo Zdanowicz | is_activated: |
| 82 | 1 | Guillermo Zdanowicz | type: boolean |
| 83 | 1 | Guillermo Zdanowicz | nullable: true |
| 84 | 1 | Guillermo Zdanowicz | email: |
| 85 | 1 | Guillermo Zdanowicz | type: string |
| 86 | 1 | Guillermo Zdanowicz | length: 255 |
| 87 | 1 | Guillermo Zdanowicz | expires_at: |
| 88 | 1 | Guillermo Zdanowicz | type: datetime |
| 89 | 1 | Guillermo Zdanowicz | created_at: |
| 90 | 1 | Guillermo Zdanowicz | type: datetime |
| 91 | 1 | Guillermo Zdanowicz | updated_at: |
| 92 | 1 | Guillermo Zdanowicz | type: datetime |
| 93 | 1 | Guillermo Zdanowicz | nullable: true |
| 94 | 1 | Guillermo Zdanowicz | manyToOne: |
| 95 | 1 | Guillermo Zdanowicz | category: |
| 96 | 1 | Guillermo Zdanowicz | targetEntity: Category |
| 97 | 1 | Guillermo Zdanowicz | inversedBy: jobs |
| 98 | 1 | Guillermo Zdanowicz | joinColumn: |
| 99 | 1 | Guillermo Zdanowicz | name: category_id |
| 100 | 1 | Guillermo Zdanowicz | referencedColumnName: id |
| 101 | 1 | Guillermo Zdanowicz | lifecycleCallbacks: |
| 102 | 1 | Guillermo Zdanowicz | prePersist: [ setCreatedAtValue ] |
| 103 | 1 | Guillermo Zdanowicz | preUpdate: [ setUpdatedAtValue ] |
| 104 | 1 | Guillermo Zdanowicz | </pre> |
| 105 | 1 | Guillermo Zdanowicz | |
| 106 | 1 | Guillermo Zdanowicz | mcedit src/JobeetBundle/Resources/config/doctrine/Affiliate.orm.yml |
| 107 | 1 | Guillermo Zdanowicz | |
| 108 | 1 | Guillermo Zdanowicz | <pre> |
| 109 | 1 | Guillermo Zdanowicz | # src/JobeetBundle/Resources/config/doctrine/Affiliate.orm.yml |
| 110 | 1 | Guillermo Zdanowicz | JobeetBundle\Entity\Affiliate: |
| 111 | 1 | Guillermo Zdanowicz | type: entity |
| 112 | 1 | Guillermo Zdanowicz | table: affiliate |
| 113 | 1 | Guillermo Zdanowicz | id: |
| 114 | 1 | Guillermo Zdanowicz | id: |
| 115 | 1 | Guillermo Zdanowicz | type: integer |
| 116 | 1 | Guillermo Zdanowicz | generator: { strategy: AUTO } |
| 117 | 1 | Guillermo Zdanowicz | fields: |
| 118 | 1 | Guillermo Zdanowicz | url: |
| 119 | 1 | Guillermo Zdanowicz | type: string |
| 120 | 1 | Guillermo Zdanowicz | length: 255 |
| 121 | 1 | Guillermo Zdanowicz | email: |
| 122 | 1 | Guillermo Zdanowicz | type: string |
| 123 | 1 | Guillermo Zdanowicz | length: 255 |
| 124 | 1 | Guillermo Zdanowicz | unique: true |
| 125 | 1 | Guillermo Zdanowicz | token: |
| 126 | 1 | Guillermo Zdanowicz | type: string |
| 127 | 1 | Guillermo Zdanowicz | length: 255 |
| 128 | 1 | Guillermo Zdanowicz | is_active: |
| 129 | 1 | Guillermo Zdanowicz | type: boolean |
| 130 | 1 | Guillermo Zdanowicz | nullable: true |
| 131 | 1 | Guillermo Zdanowicz | created_at: |
| 132 | 1 | Guillermo Zdanowicz | type: datetime |
| 133 | 1 | Guillermo Zdanowicz | manyToMany: |
| 134 | 1 | Guillermo Zdanowicz | categories: |
| 135 | 1 | Guillermo Zdanowicz | targetEntity: Category |
| 136 | 1 | Guillermo Zdanowicz | joinTable: |
| 137 | 1 | Guillermo Zdanowicz | name: category_affiliate |
| 138 | 1 | Guillermo Zdanowicz | joinColumns: |
| 139 | 1 | Guillermo Zdanowicz | affiliate_id: |
| 140 | 1 | Guillermo Zdanowicz | referencedColumnName: id |
| 141 | 1 | Guillermo Zdanowicz | inverseJoinColumns: |
| 142 | 1 | Guillermo Zdanowicz | category_id: |
| 143 | 1 | Guillermo Zdanowicz | referencedColumnName: id |
| 144 | 1 | Guillermo Zdanowicz | lifecycleCallbacks: |
| 145 | 1 | Guillermo Zdanowicz | prePersist: [ setCreatedAtValue ] |
| 146 | 1 | Guillermo Zdanowicz | </pre> |
| 147 | 1 | Guillermo Zdanowicz | |
| 148 | 1 | Guillermo Zdanowicz | |
| 149 | 1 | Guillermo Zdanowicz | *Generamos los archivos de Entidades* |
| 150 | 1 | Guillermo Zdanowicz | |
| 151 | 1 | Guillermo Zdanowicz | php app/console doctrine:generate:entities JobeetBundle |
| 152 | 2 | Guillermo Zdanowicz | |
| 153 | 3 | Guillermo Zdanowicz | *Si no hemos creado la base de datos y tenemos configuraod en app/config/parameters.yml el acceso, podemos crearla* |
| 154 | 3 | Guillermo Zdanowicz | |
| 155 | 4 | Guillermo Zdanowicz | ejemplo de parameters.yml |
| 156 | 4 | Guillermo Zdanowicz | |
| 157 | 4 | Guillermo Zdanowicz | <pre> |
| 158 | 4 | Guillermo Zdanowicz | parameters: |
| 159 | 4 | Guillermo Zdanowicz | database_host: 127.0.0.1 |
| 160 | 4 | Guillermo Zdanowicz | database_port: null |
| 161 | 4 | Guillermo Zdanowicz | database_name: s27 |
| 162 | 4 | Guillermo Zdanowicz | database_user: root |
| 163 | 4 | Guillermo Zdanowicz | database_password: MICLAVE_MYSQL |
| 164 | 4 | Guillermo Zdanowicz | mailer_transport: smtp |
| 165 | 4 | Guillermo Zdanowicz | mailer_host: 127.0.0.1 |
| 166 | 4 | Guillermo Zdanowicz | mailer_user: null |
| 167 | 4 | Guillermo Zdanowicz | mailer_password: null |
| 168 | 4 | Guillermo Zdanowicz | secret: dedeb278ce6f7db6ea0c78fa04499b87e418f613 |
| 169 | 4 | Guillermo Zdanowicz | </pre> |
| 170 | 4 | Guillermo Zdanowicz | |
| 171 | 3 | Guillermo Zdanowicz | php app/console doctrine:database:create |
| 172 | 3 | Guillermo Zdanowicz | |
| 173 | 2 | Guillermo Zdanowicz | *Luego trasladamos a la base de datos el esquema, en este caso conviene ya tener creada la base de datos segun lo configurado en parameters.yml* |
| 174 | 2 | Guillermo Zdanowicz | |
| 175 | 2 | Guillermo Zdanowicz | php app/console doctrine:schema:update --force |
| 176 | 5 | Guillermo Zdanowicz | |
| 177 | 5 | Guillermo Zdanowicz | |
| 178 | 5 | Guillermo Zdanowicz | Referencias: |
| 179 | 5 | Guillermo Zdanowicz | |
| 180 | 5 | Guillermo Zdanowicz | http://symfony.com/doc/current/book/doctrine.html |