I'm using Django for backend, but for some reason, I want to use Laravel beside Django and share the database between them. so the same database for Django and Laravel. but the problem is that Django migrations are not equal to Laravel migrations so the database is different from ( for example constraints and indexes and some other options).
Is this going to break backend if I use Django as the primary database and use Laravel as a secondary backend?
If true, how I can use Django and Laravel in the same database?
-
3You can create migrations using either Django or Laravel and use API to transfer data to each other.user379888– user3798882020-05-31 10:19:02 +00:00Commented May 31, 2020 at 10:19
-
@fuddin no I don't want to use API. I want to be separate :)Nimdeveloper– Nimdeveloper2020-05-31 10:43:42 +00:00Commented May 31, 2020 at 10:43
1 Answer
Your database does not depend on Django or Laravel. It just stores data.
Constraints, triggers, indexes, etc are stored on the database itself, and they are completely independent of your framework. Frameworks just abstract the methods and provide easy methods to manage your database. At the core, they use the same commands which are provided by the database. The names of constraints are irrelevant, you can give whatever names you want, frameworks just provide their own uniform naming pattern, which can be customized by the user. So they can be used on both Django and Laravel or any other framework/programming language. That's the main purpose of having a database, to store data in a structured manner so it can be used by any language/framework
Since you already have migrations in Django, there's no need to create the migrations again in laravel. Just reuse the Django database and make your laravel application to properly handle the data (that part is completely in your control)
4 Comments
categories_parents_id_6dcc3f37_fk_categories_id, and same table constraints in Laravel is categories_parent_foreign, if I use Laravel form to get data, this will work? what about insert data?categories_parents_id_6dcc3f37_fk_categories_id and categories_parent_foreign are just names for the foreign key constaints. You can change them to whatever you want, it's functioning won't differ