https://github.com/hxtree/db-to-doctrine-entity
A simple project to generate Doctrine entities from an existing database.
https://github.com/hxtree/db-to-doctrine-entity
Last synced: about 2 months ago
JSON representation
A simple project to generate Doctrine entities from an existing database.
- Host: GitHub
- URL: https://github.com/hxtree/db-to-doctrine-entity
- Owner: hxtree
- Created: 2021-06-09T22:10:43.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-09T22:13:50.000Z (almost 4 years ago)
- Last Synced: 2025-02-12T10:34:56.983Z (3 months ago)
- Language: PHP
- Size: 7.81 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DB To Doctrine Entity
A simple project to generate Doctrine entities from an existing database.
## Setup
Configure database connection information:
```sql
vim bootstrap.php
```Next run Doctine bin file:
```sql
php vendor/bin/doctrine orm:convert-mapping -f --from-database annotation Entity/
```## Debugging Tips:
Doctrine may not support some table options used, such as ENUMs or bit. In which case it is important to add those table
to exclude filter in bootstrap.php.
```
// exclude any tables here
$conn->getConfiguration()->setFilterSchemaAssetsExpression('~^(?!TableName)~');
```Find tables containing ENUM:
```sql
select col.table_schema as database_name, col.table_name, col.ordinal_position as column_id, col.column_name,
col.data_type, trim(leading 'enum' from col.column_type) as enum_values
from information_schema.columns col
join information_schema.tables tab on tab.table_schema = col.table_schema
and tab.table_name = col.table_name
and tab.table_type = 'BASE TABLE'
where col.data_type in ('enum')
and col.table_schema not in ('information_schema', 'sys', 'performance_schema', 'mysql')
and col.table_schema = 'INSERT DATABASE NAME'
order by col.table_schema, col.table_name, col.ordinal_position;
```Find Tables containing BIT type:
```sql
select col.table_schema as database_name, col.table_name, col.ordinal_position as column_id, col.column_name,
col.data_type, trim(leading 'bit' from col.column_type) as bit_values
from information_schema.columns col
join information_schema.tables tab on tab.table_schema = col.table_schema
and tab.table_name = col.table_name
and tab.table_type = 'BASE TABLE'
where col.data_type in ('bit')
and col.table_schema not in ('information_schema', 'sys', 'performance_schema', 'mysql')
and col.table_schema = 'INSERT DATABASE NAME'
order by col.table_schema, col.table_name, col.ordinal_position;
```