I have decided to migrate from my CodeIgniter app to laravel specially for their rails-likely handling of the database.
The problem though is that i have 800mb of database to migrate. How can I do this in a good and fast way? The tutorials i have seen is based on old laravel models to new ones. Which makes me confused.
I also use codeigniter's crypt library for the user passwords. How can I migrate this?
Databases are pretty much the same in Laravel or Codeigniter, if your tables are good the way they are for you and they have a primary key named id (this also is not mandatory) you can just connect with Laravel in your database and it will work just fine.
For your new tables, you can create new migrations and Laravel will not complaint about this.
Well, but if you really need to migrate to a whole new database, you can do the following:
1) rename the tables you need to migrate
php artisan migrate:make
2) create all your migrations with your and migrate them:
php artisan migrate
3) use your database server sql utility to copy data from one table to another, it will be way faster than creating everything in Laravel, believe me. Most databases will let you do things like:
INSERT INTO users (FirstName, LastName)
SELECT FirstName, LastName
FROM users_old
And in some you'll be able to do the same using two different databases and columns names
INSERT INTO NEWdatabasename.users (firstName+' '+Lastname, email)
SELECT name, email
FROM OLDdatabasename.
Or you can just export data to a CSV file and then create a method in your Laravel seeding class to load that data into your database, with a lot of data to import, you just have to remember to execute:
DB::disableQueryLog();
So your PHP doesn't run out of memory.
See? There are a lot of options, probably many more, so pick one and if you need help, shoot more questions.
Related
I like to migrate my database but I don't want alembic_version table in my database. It is possible without this alembic_version table. Is there any other solution or it is possible or not.
I have several tables that I have created through migration. Then, what happens if I change the table structure directly from PHPMYADMIN without using migration? What if my backend team pulls my project, then runs the "php artisan migrate" command. Is the database on my backend team the same as the database that I have?
If you make changes through phpMyAdmin, these will only be visible to you. You should change the migrations, or if you can't change the original because you don't want to reset the database, you should create a new migration to alter the table. Check the documentation for altering tables here: https://laravel.com/docs/5.7/migrations#modifying-columns
I want to make test on a database which is already using by others.
So I came up with the idea that I create a new DB and creates all the tables functions packages from old DB. I made the tests, it's OK to use new DB but I want to switch two DB.
I thought that I could simply change the username after deleting old DB but apparently I cant do that.
Is there an alternative way to change Username In ORACLE DB?
I'm new in developing in MVC and I have some doubts in how to build the Models. I don't know if I must build them in terms of Database Tables or in other terms.
I have for example this 5 tables:
Domain
Category_Domains
Countries_Domains
Categories
Countries
How can i Build a Models to do actions in these Database Tables. Should I built the SQL commands to Insert, Delete and Update for each one of these Tables or I should do other thing than this?
Sorry if I not explain well.
The best advice I can give you is to look into the entity framework. Using this framework, you can create a data connection to your SQL database and the framework will create your model based on your table structure, including relationships.
Doing this will ensure your database is modelled correctly and kept in sync at all times
I am very new to rails, and from what i have been reading and watching in tutorials only helps me build things from scratch, creating new databases and the models at the same time.
my company has an accounting / construction project management software system that was recently warehoused into ms sql server.
how would i build the models from the existing tables structure . im not needing delete update. im looking to create a remote web based querying tool.
thanks.
Connecting Rails to SQL server is a separate issue which has been covered a bit by some previous stackoverflow questions.
You can generate models corresponding to your existing tables in the same way as you would for new tables and then use a number of methods to handle places where your existing table and field names don't follow Rails naming conventions. e.g. if you create a Project model then Rails would expect the table to be called projects (plural). If your table was called project you would need to add to your model:
class Project < ActiveRecord::Base
set_table_name "project"
end
Similarly, if the primary key for your table was project_id rather than just id you could do:
class Project < ActiveRecord::Base
primary_key = 'project_id'
end
you can use sql manager to create the database.
rails use sqlite3 by default.