Menu
  • HOME
  • TAGS

Is it necessary to write down() for every up() in migration in laravel?

laravel,migration,database-migration,laravel-migrations

In the down method of a migration, you undo the changes you made within the up method. This method is called when you rollaback a migration with the artisan migrate:rollback command. In your case it would look something like this: public function down() { // Laravel doesn't have a method...

Is there a way to create a citext field using Laravel 5 Migrations?

php,postgresql,laravel,laravel-5,laravel-migrations

Yes, this can be done. It requires extending a few of the core files, but it is doable. Specifically, you will need a new connection, schema grammar, and blueprint. First, create a new directory under your app directory to hold your custom files. For example, app/Extension. The files placed in...

PDOException (1044) SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge'

laravel,laravel-5,database-migration,laravel-migrations

Put a .env file in your root directory and paste this code there. APP_ENV=local APP_DEBUG=true APP_KEY=1CaND3OKKvOGSBAlCg6IyrRmTQWwZjOO DB_HOST = localhost DB_DATABASE = YOUR_DATABASE_NAME DB_USERNAME = USER_NAME DB_PASSWORD = PASSWORD CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync MAIL_DRIVER=smtp MAIL_HOST=mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null Update your database, username and password field here and it should solve your problem....

Column not found: 1054 Unknown issue in laravel 4

php,laravel,laravel-4,laravel-migrations

I am very confident that actually the teacher_subject_id does not exist in your table subject_start. You can doublecheck it if you open your mysql console and type in desc subject_start; This will display you all the column in this table that exist. If it is your intention to use different...

create first user in Laravel 5

laravel,laravel-5,laravel-migrations

You don't need to create any table manually (and you shouldn't). In Laravel you have migrations that help you quickly create tables in your database and seeds (where you can put initial data to those tables). In fresh Laravel installation you have 2 ready migrations (for creating users and password_resets...

Update enum column in Laravel migration using PostgreSQL

postgresql,laravel,laravel-5,laravel-migrations

Laravel use constraint on character varying for enum. Assuming there is a table mytable with an enum column status, we have to drop the constraint (named tablename_columnname_check) then add it in a migration like this: DB::transaction(function () { DB::statement('ALTER TABLE mytable DROP CONSTRAINT mytable_status_check;'); DB::statement('ALTER TABLE mytable ADD CONSTRAINT mytable_status_check...

migration rollback reverts the previous schema but previous data is lost

laravel,migration,database-migration,laravel-migrations

No, sorry. Migrations only take care of the database structure. It has nothing to do with your data. In fact, by default when you roll a previous migration back, the rollback performs a table drop, which means that all data within that table is lost.

How do Laravel migrations work?

php,laravel,laravel-5,laravel-migrations

Migrations are a type of version control for your database. They allow a team to modify the database schema and stay up to date on the current schema state. Migrations are typically paired with the Schema Builder to easily manage your application's schema. With migrations you don't need to create...

Should I gitignore seeder files in Laravel 5?

git,laravel,production-environment,laravel-migrations,laravel-seeding

No. Seed files should be part of your repo. Of course you shouldn't run them in production, but a developer checking your code out should be able to migrate and seed their database with dummy data. They can't very well do that if you've gitignore-d the directory contents.

Databse migration throws error while seeding two timestamp columns laravel 5

php,mysql,laravel-5,create-table,laravel-migrations

timestamps() method adds both created_at and updated_at columns. Also this method doesn't accept any arguments. http://laravel.com/api/5.0/Illuminate/Database/Schema/Blueprint.html#method_timestamps http://laravel.com/docs/5.0/schema...

How to convert Laravel migrations to raw SQL scripts?

sql,laravel,laravel-migrations

Use the migrate command You can add the --pretend flag when you run php artisan migrate to output the queries to the terminal: php artisan migrate --pretend This will look something like this: Migration table created successfully. CreateUsersTable: create table "users" ("id" integer not null primary key autoincrement, "name" varchar...

Laravel Migrations Deleted File

php,sqlite,laravel,laravel-migrations

The first error: [ErrorException] include(/home/vagrant/Code/Laravel/database/migrations/2015_05_24_211527_create_articles_table.php): failed to open stream: No such file or directory should be fixed executing composer dump-autoload. About the second one: "However when I checked my database (Note that I have deleted and recreated it in order to combat my issue) and there are only two records...

Subclassing Migrator not working for namespaced migration

laravel-4,namespaces,illuminate-container,laravel-migrations

Ok, I've gotten this working. It turns out that the Medium.com article assumes you'd just know where to put the files he talks about, which I didn't. I've made several changes, and now everything is working correctly: I created a new appTruancy\providers subfolder, and add it to composer.json I moved...