Comments (5)
I can reproduce this issue. I'm using MySQL though with the mysql2 adapter.
Reproduction Steps
I created a dummy class
class Foobar < ActiveRecord::Base
field :name, as: :string
field :data, as: :integer
end
I ran auto_upgrade!
irb(main):001:0> Foobar => Foobar(Table doesn't exist) irb(main):002:0> Foobar.auto_upgrade! [MiniRecord] Creating Table foobars (542.8ms) CREATE TABLE `foobars` (`id` int(11) auto_increment PRIMARY KEY) ENGINE=InnoDB [MiniRecord] Adding column foobars.name (514.5ms) ALTER TABLE `foobars` ADD `name` varchar(255) [MiniRecord] Adding column foobars.data (444.6ms) ALTER TABLE `foobars` ADD `data` int(11) => nil
I changed the type to text
class Foobar < ActiveRecord::Base
field :name, as: :string
field :data, as: :text
end
I ran auto_upgrade! again
irb(main):003:0> Foobar.auto_upgrade! => nil
I double check column type in MySQL and it is still an integer.
MariaDB [test_app_development]> describe foobars; +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(255) | YES | | NULL | | | data | int(11) | YES | | NULL | | +-------+--------------+------+-----+---------+----------------+
from mini_record.
I found the issue and I am able to get it to change the column type. I will submit a PR soon.
You can ignore my puts statements prefaced with "[JAMES]".
irb(main):024:0> Foobar.auto_upgrade! [JAMES] ---- TEST [JAMES] id [JAMES] name [JAMES] new_attr: {}, changed: false [JAMES] new_type: string [JAMES] data [MiniRecord] Detected schema change for foobars.data#type from :integer to :text [JAMES] new_attr: {:type=>:text}, changed: true [JAMES] new_type: text [MiniRecord] Changing column foobars.data to new type text (721.5ms) ALTER TABLE `foobars` CHANGE `data` `data` text DEFAULT NULL => nil
Now I look at my DB and the column is text now!
MariaDB [test_app_development]> describe foobars; +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(255) | YES | | NULL | | | data | text | YES | | NULL | | +-------+--------------+------+-----+---------+----------------+
from mini_record.
@burnt43, thank you very much! It's amazing responce speed! I'll wait for a new release with your PR! :)
from mini_record.
@Xanders, if you need this quickly you can update your Gemfile and point it to my github burnt43/mini_record until the PR is fix and accepted.
from mini_record.
@burnt43, thank you for a tip! :) I don't need it so quickly. :)
from mini_record.
Related Issues (20)
- Issue about primary keys HOT 2
- ActiveRecord - Abstract class bug. HOT 1
- mini_record incompatible with Rails 4.0 HOT 4
- Idea for handling changing column names HOT 6
- macro facility - useful/interesting? HOT 3
- sqlite3 rewrites the table on every auto_upgrade HOT 2
- Problems with SQLite HOT 2
- MiniRecord don't work without logger HOT 4
- has_and_belongs_to_many join table name issues HOT 1
- wrong table name. bug introduced in my last PR HOT 1
- auto_upgrade! fails because of attempting to add duplicate indexes
- auto_upgrade! sometimes breaks has_and_belongs_to_many associations
- Partial indexes for PostgreSQL?
- PostgreSQL limitless columns? HOT 3
- how to use mini_record in sinatra?
- "Unsupported number of args for ActiveRecord::ConnectionAdapters::TableDefinition.new() (ArgumentError)" HOT 2
- PostgreSQL booleans not supported HOT 1
- Not related: GoTasks for Mac
- auto_upgrade! NameError: no member 'limit' in struct HOT 2
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 mini_record.