Rails Exporter Plugin works as a seeds generator. It creates ruby code to fill each table with valid data.
The following Workbench attributes are supported and considered during the creation:
Table comments are converted into ruby comments.
Sets all default values, if valid.
Foreign keys are used in the CREATE command of rails data rows. 1:1, 1:n: the referenced columns are filled with a releating parent object by random. n:m: creates additional join tables, filled with a related object by random. polymorphic: uses random relation from multiple referenced tables.
Limit values are considered.
Unique values are considered, Rails Exporter tries to change the value to a unqiue one. If it fails after several attempts, the seed creation for that table ends. Relations and indices are considered in a dynamic created ruby routine.
Before creating the rails files, the tables are checked [and renamed to "_y", if double or a prefix is added, if it starts with a number ("60">"a60")] and keys are memorized. By that, Rails Exporter Plugin sorts the tables for correct seeds creation. For example: all tables that are only child tables of a relation, but are not parents, are sorted to the end, and vice versa.
Depending on the rails field type, the seed values are created as follows:
Random number between 1 and 100.000
Random Word plus a random length-random number prefix. [e.g. Marillion_1981]
Fixed graphic pixel binary coded value
Random T(rue) or F(alse)
Random Word plus a random length-random number prefix. [e.g. Marillion_1982], max length 256
Random decimal value between 1,1 and 100000,999
Random decimal value between 1,1 and 100000,999999
Random date between [1971-12-04 and 2013-12-04]
Random time between [00:00:00.000 and 23:59:00.000]
Random datetime between [1971-12-04 23:00:00.000 and 2013-12-04 23:59:59.000]
The seeds actions are displayed in the command line/console, ending with a finished message. You may alter the seeds logic and content to your own needs in the lua script source code of the plugin.
Rails Exporter Plugins converts MySQL columnd types to rails types:
- INT, INTEGER, NUMERIC, TINYINT, BIGINT, SMALLINT, MEDIUMINT, BIT > INTEGER
- FLOAT, DOUBLE > FLOAT
- DECIMAL > DECIMAL
- BOOLEAN, BOOL > BOOLEAN
- TIME > TIME
- DATE > DATE
- DATETIME, TIMESTAMP > DATETIME
- BINARY, BLOB > BINARY
- TEXT > TEXT
- VARCHAR, YEAR, ENUM and everything else as a default > STRING