Git Product home page Git Product logo

iseed's People

Contributors

alexw23 avatar andjelicsasa avatar araneadev avatar atmonshi avatar atrakeur avatar dinandmentink avatar giovannipds avatar gmsantos avatar ivanbatic avatar jxlwqq avatar lflaszlo avatar maras0830 avatar mattrabe avatar nuernbergera avatar petercoles avatar puralogica avatar reizinixc avatar stltt avatar tihomiro avatar zayedadel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iseed's Issues

what happend with L5 branch???

Thanks for your hard work,
It seems you deleted the dev-master branch, my cuestion is, will you enabled dev-master branch again? ? will be some changes??

thanks again!!

Question: seeding only results of a select query

This is not an issue, rather a question.

I use another laravel provider which seeds 2 rows in 2 tables. I need all rows in 3 tables for the application to work. Do you have a way where I could generate a seed from results of a eloquent query? Model::where('id','>','2')

Implement ::class notation in updateDatabaseSeederRunMethod

It would be nice if by default the seeders were stored with ::class notation instead of plain strings in DatabaseSeeder.php. It would improve consistency with L 5.1 & L 5.2. Also makes it easier to jump between files and classes in some IDEs such as PHPStorm.

public function updateDatabaseSeederRunMethod($className)
    {

        $className = "{$className}::class";

        $databaseSeederPath = base_path() . config('iseed::config.path') . '/DatabaseSeeder.php';

        $content = $this->files->get($databaseSeederPath);
        if(strpos($content, "\$this->call({$className})")===false)
        {
            if(strpos($content, '#iseed_start') && strpos($content, '#iseed_end') && strpos($content, '#iseed_start') < strpos($content, '#iseed_end'))
            {
                $content = preg_replace("/(\#iseed_start.+?)\#iseed_end/us", "$1\$this->call({$className});\n\t\t#iseed_end", $content);
            }
            else
            {
                $content = preg_replace("/(run\(\).+?)}/us", "$1\t\$this->call({$className});\n\t}", $content);
            }
        }

        return $this->files->put($databaseSeederPath, $content) !== false;
    }

Is there a way to generate seeds ignoring columns?

When I generate seeds with autoincrement columns the database lost the reference of those fields when I have to run/restore the seed, causing a duplicated key error in the moment that I add a new register of this table. This is commonly happens with id primary keys that I have to delete it from generated seed. Because of that I need to know if there is any way to generate the seed ignoring the autoincrement id columns.

My database is Postgres.

Congrats for the project!

[ Enhancement ] - className by exploding _

In order to avoid Laravel from thinking that the Class just created is in a subfolder.
This happen for all relational tables.
Here's my code:

Line 107 Iseed.php

public function generateClassName($table) {
$tableString = '';
$tableName = explode('_', $table);
foreach($tableName as $tableNameExploded) {
$tableString .= ucfirst($tableNameExploded);
}
return ucfirst($tableString) . 'TableSeeder';
}

Already tested and perfectly working, also with non-relational tables

Unable to install on Laravel 5.2

I'm using Laravel 5.2 and want to install this package but I cannot install it. Here is my error after I run composer update :
screenshot from 2017-01-16 14-00-12
screenshot from 2017-01-16 14-01-06

Is it possible to install it on Laravel 5.2?

Laravel 5.4 Support?

I get this error when I run php artisan comand after regisering this package.
Call to undefined method Illuminate\Foundation\Application::share()
I'm guessing the share() function has been renamed??

composer dump-autoload required

Hi, there is a problem, it requires to launch composer dump-autoload when new seed class is created. Maybe it's good to add dump-autoload command execution when launching php artisan iseed?

Also it adds $this->call() to DatabaseSeeder after Model::reguard(); call, it should be before. And in new Laravel 5.1 version they replaced tabs indents with spaces http://screencast.com/t/pAAUENCFzg6F

[Feature Request] Max # of rows

I'm not sure how this would play out with foreign keys, maybe it'd just need to ignore them? I have several tables I'd like to generate seeds for that exceed 1,000 rows and I only need about 50 for development purposes. It'd be awesome to be able to specify a max # of rows to be seeded from a given table.

Use truncate instead of delete

As suggested in #58 (comment)

Add a key in the config like a method or any name you want.

return array( 'path' => '/database/seeds', 'chunk_size' => 500, 'method' => 'delete' );

and in the stub file send a method var

DB::table('{{table}}')->{{method}}();

For the people with foreign keys problems, it can be solve with this:

Schema::disableForeignKeyConstraints();
$this->call(SomeTableSeeder::class);
Schema::enableForeignKeyConstraints();

does not work on Laravel 5.1

Just installed this on 5.1 but it does not work. Whatever I try I keep getting the below error! Althought php artisan vendor:publish does not seem to publish the package config file i have created it manually with no luck. Also when running the command i added the max option and still no luck.

php artisan iseed users -max=100

[ErrorException]                                             
  array_chunk(): Size parameter expected to be greater than 0

Work with Lumen

It looks like Lumen doesn't pull in some packages that iseed rely on โ€“ e.g. \Illuminate\Foundation

database connection in IseedCommand.php

Please change the hasTable check in generateFileName
https://github.com/orangehill/iseed/blob/master/src/Orangehill/Iseed/IseedCommand.php#L158
to
if (!\Schema::connection($database)->hasTable($table)) {

and add
$database = $this->option('database') ?: config('database.default');
to
https://github.com/orangehill/iseed/blob/master/src/Orangehill/Iseed/IseedCommand.php#L51

and change
https://github.com/orangehill/iseed/blob/master/src/Orangehill/Iseed/IseedCommand.php#L70
to:
list($fileName, $className) = $this->generateFileName($database, $table);

Thanks.

Sorting with max records

Hey there,

If you add --max=X parameter, is there a way to add data in descending order, so the last X records are added.

Something like:

php artisan iseed contacts --max=10 --sort=desc

Thanks in advance!

Generated seed whithout update DatabaseSeeder file

Hi guys,

search but not found generated seed whithout update DatabaseSeeder file.
I would like to update the seed file from a table but do not change the databaseSeeder file, is this possible?
Sorry my English. ๐Ÿ˜ƒ

Truncate() and foreign keys

Hi everybody,

Why using

public function run()
    {
        \DB::table('{{table}}')->truncate();

It happens issues with foreigns keys.

I think you should update this with delete.

Regards,

Class 'Illuminate\Support\Composer' not found

After updating to the latest of iseed (dev-master) I receive the following error when using composer require or composer update

2017-01-02_0-46-39

I am using L5.1. I believe that L5.1 uses Illuminate\Foundation\Composer instead of Illuminate\Foundation\Composer. I was able to put a bandaid on this by specifying a previous commit in composer.json and running composer update --no-scripts to get me by for now. If you need anything else let me know.

Thanks for all the work you do on this package. It's greatly appreciated!

Is there a way to seed all the tables?

I didn't find it...
But if there isn't it would be good to have a --allTables parameter to seed all the tables in a DB and a
--excludeTable to eventually exclude some of them.

Doesn't work with model events

Expected behaviour:
When every record is gets created, I expect my model created event to fire off to do some other things.

Actual Behaviour:
My model event created method is only called once, instead of once for each record created. This only happened to seeder files generated by iSeed. Possibly due to iSeed auto generated seeder files using bulk inserts (If I don't remember wrongly)

Suggestion: Use PHP_EOL instead of hard-coded Windows CRLF

Hi,

I am very happy about iseed, it saves me tons of work. But I use it on Linux and therefore tend to get weird Windos CRLF characters in my source code (which I occasionally edit manually).

Is there any chance that you can change this line:

private $newLineCharacter = "\r\n";

Into:

private $newLineCharacter = PHP_EOL;

Cheers,
Mikael

Fail in laravel 5.3

Hi, I use " php artisan iseed my_table " but only get
`<?php

use Illuminate\Database\Seeder;

class my_tableTableSeeder extends Seeder
{

/**
 * Auto generated seed file
 *
 * @return void
 */
public function run()
{
    \DB::table('my_table')->delete();
}

}
`
please help
thanks

Cannot create seed for large table

I have a postal code table with 700000 rows. Using this command returns nothing and no file is generated.
php artisan iseed postal_codes --force

seed ALL tables with one command

Can someone make a switch or command that enables you to create a seed file for ALL tables in a database with a single command (except for the migrations table maybe)? I'm attempting to do this myself but I'm too much of a programming noob to get it yet.

Say, for example: $php artisan iseed:all

I know this isn't really an "issue" or a bug, but I didn't know where to request this.

Thanks

Overwrites existing file without warning.

This is a really useful tool, its not a huge problem for me as I have my seed files in a repository, but an existing seed file was overwritten without warning when run from artisan. A prompt or an overwrite flag would be even better.

error when seeding from table with many records

I created a seed from a table with 14 columns and over 5000 rows but when I ran "php artisan db:seed", I got a general error: 1390 prepared statement contains too many placeholders.

I edited the seed code to make two inserts instead of seeding all of the rows in one and then it worked.

\DB::table('users')->insert(array (

iseed is not available on artisan

Laravel 5.4, here is my composer.json

{
  "name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "type": "project",
  "minimum-stability": "dev",
  "require": {
    "php": ">=5.6.4",
    "doctrine/dbal": "^2.5",
    "laracasts/utilities": ">=2.1",
    "laravel/framework": "5.4.*",
    "laravel/tinker": "~1.0",
    "league/flysystem": ">=1.0.37",
    "orangehill/iseed": "dev-master",
    "predis/predis": "^1.1",
    "talyssonoc/react-laravel": "dev-master",
    "tcg/voyager": "dev-master"
  },
  "require-dev": {
    "barryvdh/laravel-ide-helper": "^2.3",
    "fzaninotto/faker": "~1.4",
    "laravel/homestead": "^5.1",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.7",
    "phpspec/phpspec": "^3.0"
  },
  "autoload": {
    "classmap": [
      "database"
    ],
    "psr-4": {
      "LinguobotAdmin\\": "app/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    }
  },
  "scripts": {
    "post-root-package-install": [
      "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "php artisan key:generate"
    ],
    "post-install-cmd": [
      "Illuminate\\Foundation\\ComposerScripts::postInstall",
      "php artisan optimize",
      "echo 'Change .env file credentials to your environment, so database and caching connections would work'"
    ],
    "post-update-cmd": [
      "Illuminate\\Foundation\\ComposerScripts::postUpdate",
      "php artisan ide-helper:generate",
      "php artisan ide-helper:meta",
      "php artisan optimize"
    ]
  },
  "config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "optimize-autoloader": true
  }
}

Laravel 5.3 changes

Hi everyone!

Laravel 5.3 is around the corner and this package needs some changes to work with it.

See the getData() method:

    /**
     * Get the Data
     * @param  string $table
     * @return Array
     */
    public function getData($table, $max)
    {
        if (!$max) {
            return \DB::connection($this->databaseName)->table($table)->get();
        }

        return \DB::connection($this->databaseName)->table($table)->limit($max)->get();
    }

Prior to L5.3 this method returns an array but in L5.3+ it returns a Collection that needs to be casted as an array.

Dirty quick fix to allow this package to work with both L5.3 and prior versions.

    /**
     * Repacks data read from the database
     * @param  array|object $data
     * @return array
     */
    public function repackSeedData($data)
    {
        // Check if $data is an array
        if (!is_array($data)) {
            $data = $data->toArray();
        }

        $dataArray = array();
        if (is_array($data)) {
            foreach ($data as $row) {
                $rowArray = array();

                foreach ($row as $columnName => $columnValue) {
                    $rowArray[$columnName] = $columnValue;
                }
                $dataArray[] = $rowArray;
            }
        }
        return $dataArray;
    }

Cheers

Error:: While composer update

We receive this error while doing composer update

Error Output: PHP Fatal error: Call to undefined method Illuminate\Foundation\Application::configPath() in /home/muthu/project/xport/server/vendor/orangehill/iseed/src
/Orangehill/Iseed/IseedServiceProvider.php on line 67

Compact format

Is it possible to generate seeder data in more compact format?

For example now, table with 20k rows(US cities coordinates) size in iseed format is 5.7Mb, but in SQL dump format it takes just 1Mb, gzipped SQL dump - just 0.35Mb.

Documentation

You should really put the "Composer Update" part before the part to include the Service provider... if the provider has already been added to the Config before calling "Composer Update" you will get an error.

[Question] Iseed Backup

Hello everyone.

My question is, can iseed be used as a backup of the information from a table? For example, I want to do regular backup of a table data in seed format every day or maybe every week automatically and without overriding the old seeders. Is there a way to do that?

Tagging Repo

Is it possible to add some tags to the current repo - I wan't to lock in my versioning? I.e. current build could be 1.1.0

RuntimeException

Hi, I got a exception when install iseed for Laravel 5:

  [RuntimeException]
  Could not scan for classes inside "/home/vagrant/Code/rsct/vendor/orangehill/iseed/src/Orangehill/Iseed/Exceptions.php" which does not appear to be a file nor a folder

I'm not clear what's the reason, please help me out, thanks!

sqlite require unique index names

Sqlite requires that the index name is unique database-wide. We could add a flag to prepend the table name for the sake of uniqueness to each id when converting from say, MySQL to Sqlite (for migrations and seeding used in testing).

Laravel 5.4

- orangehill/iseed dev-master requires illuminate/support ~5.3.8 -> satisfiable by laravel/framework[v5.3.28], illuminate/support[v5.3.16, v5.3.23].
- orangehill/iseed dev-master requires illuminate/support ~5.3.8 -> satisfiable by laravel/framework[v5.3.28], illuminate/support[v5.3.16, v5.3.23].
- don't install laravel/framework v5.4.0|don't install illuminate/support v5.3.16
- don't install laravel/framework v5.4.0|don't install illuminate/support v5.3.23
- Can only install one of: laravel/framework[v5.4.0, v5.3.28].
- Installation request for laravel/framework 5.4.* -> satisfiable by laravel/framework[v5.4.0].
- Installation request for orangehill/iseed dev-master -> satisfiable by orangehill/iseed[dev-master].

Laravel 5 support

Hi, could you please make this package avaible to use with laravel 5.

Class TablenameTableSeeder does not exist

After trying out this I got the following error:

Class TablenameTableSeeder does not exist

I'm trying to export from one environment to another. Should iseed be installed on the new environment also?

use ->delete instead of truncate() and other issue

Hello,

I just tested your package and saves alot of work. thanks! ;)
meanwhile i've detected 1 issue and have another suggestion:

1st in seed.stub use \DB::table('{{table}}')->truncate(); instead of \DB::table('{{table}}')->delete();
delete() does not reset the autoincrements fields and there is no need to save undo states. truncate is faster (I use truncate because i do reset all database at once on every migrate:refresh).

in iseed.php you have:
if(strpos($content, '$this->call('UsersTableSeeder')')===false)
$content = preg_replace("/(run().+?)}/us", "$1\t$this->call('{$className}');\n\t}", $content);

should be
if(strpos($content, "$this->call('{$className}')")===false)
$content = preg_replace("/(run().+?)}/us", "$1\t$this->call('{$className}');\n\t}", $content);

without this you are allways adding same class to DatabaseSeeder.php

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.