Comments (7)
No, this seems to be a bug. The whole idea was to generate migrations that resembles the database as closely as Laravel Migrations allow. Both float
and double
are available, so this shouldn't happen.
Thanks for reporting this, will take a look at it.
from migrations-generator.
👍 Thanks. I've made a 1:1 comparison between my self-written migrations and the ones generated using your package.
They're almost 100% equal. I recommend a tool called Toad (http://www.quest.com/toad-for-mysql/) for comparisons. I use it for servers where native migrations aren't possible.
from migrations-generator.
I'm looking into it. It looks like it is the defaults precision/scale of Doctrine.
Edit: Yeah, so we're forcing decimal, double and float to specify their precision and scale, but there's no way to tell from the column details obtained from Doctrine whether or not those are default values or really those specified in the database...
Reading the doctrine docs (http://docs.doctrine-project.org/en/2.0.x/reference/annotations-reference.html), they say the following:
precision: The precision for a decimal (exact numeric) column (Applies only for decimal column)
scale: The scale for a decimal (exact numeric) column (Applies only for decimal column)
Thus it looks like we should only apply precision/scale to decimal and not offer the ability to specify those for float/double.
from migrations-generator.
@tomzx I'd second that.
from migrations-generator.
There's one thing to consider though, the current code of laravel will force float to be (8, 2) when you use ->float('my_column').
from migrations-generator.
Still not sure why it converts double fields to floats...
from migrations-generator.
Because the double
type does not exist in Doctrine, they call it float
. Here's the list of available types: http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html.
If you want to do it properly (respecting Doctrine), the SQL float
type does not exist, and you must replace the type float
with double
when you are about to generate the Blueprint
call ($table->float() -> $table->double()).
In other words:
Currently:
Source (in DB) | Doctrine type | Final (migrations-generator currently generates) |
---|---|---|
float | float | float |
double | float | float |
What it should do (respecting Doctrine):
Source (in DB) | Doctrine type | Final (migrations-generator should generate) |
---|---|---|
float | float | double |
double | float | double |
Thus it is not possible, at least using Doctrine, to generate the appropriate types due to the loss of information in the transformation process.
from migrations-generator.
Related Issues (20)
- Feature Request? !Schema::hasTable HOT 1
- ->increment() not generated AUTO_INCREMENT HOT 1
- ignore fields after created_at
- laravel5.8 There are more Warning HOT 1
- How to generate migrations for Oracle HOT 1
- Support for Postgresql hstore. HOT 1
- Laravel 6.0 Compatibility HOT 27
- Support option of --ignore-created-migration HOT 2
- Namespace accident HOT 2
- Installation via composer require --dev "xethron/migrations-generator" failing HOT 1
- Not Working with Old database enum values HOT 1
- PSR-0 problem in laravel-4-generators: Class names and file locations do not match HOT 1
- Laravel 7 support HOT 2
- Not working for Laravel 5.8 HOT 1
- 'migrations' table was not updated HOT 1
- Undefined property: stdClass::$column_name HOT 3
- Migrations generator working with Laravel 7.11 HOT 2
- Support for postgres HOT 1
- Is that will be available for Laravel 8? HOT 1
- not working on laravel 9 what we should do now HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from migrations-generator.