| 932 | 932 | |
|---|
| 933 | 933 | Symfony can use the Creole database access layer to generate a `schema.yml` file from an existing database, thanks to introspection (the capability of databases to determine the structure of the tables on which they are operating). This can be particularly useful when you do reverse-engineering, or if you prefer working on the database before working on the object model. |
|---|
| 934 | 934 | |
|---|
| 935 | 935 | In order to do this, you need to make sure that the project `propel.ini` file points to the correct database and contains all connection settings, and then call the `propel-build-schema` command: |
|---|
| 936 | 936 | |
|---|
| 937 | 937 | > php symfony propel:build-schema |
|---|
| 938 | 938 | |
|---|
| 939 | 939 | A brand-new `schema.yml` file built from your database structure is generated in the `config/` directory. You can build your model based on this schema. |
|---|
| 940 | 940 | |
|---|
| 941 | 941 | The schema-generation command is quite powerful and can add a lot of database-dependent information to your schema. As the YAML format doesn't handle this kind of vendor information, you need to generate an XML schema to take advantage of it. You can do this simply by adding an `xml` argument to the `build-schema` task: |
|---|
| 942 | 942 | |
|---|
| 944 | 944 | |
|---|
| 945 | 945 | Instead of generating a `schema.yml` file, this will create a `schema.xml` file fully compatible with Propel, containing all the vendor information. But be aware that generated XML schemas tend to be quite verbose and difficult to read. |
|---|
| 946 | 946 | |
|---|
| 947 | 947 | >**SIDEBAR** |
|---|
| 948 | 948 | >The propel.ini configuration |
|---|
| 949 | 949 | > |
|---|
| 950 | 950 | >The `propel-build-sql` and `propel-build-schema` tasks don't use the connection settings defined in the `databases.yml` file. Rather, these tasks use the connection settings in another file, called `propel.ini` and stored in the project `config/` directory: |
|---|
| 951 | 951 | > |
|---|
| 952 | 952 | > |
|---|
| 953 | 953 | > propel.database.createUrl = mysql://login:passwd@localhost |
|---|
| 954 | 954 | > propel.database.url = mysql://login:passwd@localhost/blog |