I have the database entities in my Symfony application, I have created another table in the database and I want to download it as an entity in my program. When I execute the following line I get that there are tables that already exist.
php bin/console make:migration
How can I update the entities and create only the ones that are not there?
Related
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 am a beginner in this. I am working on this ASP.NET Core MVC project where I have two tables: Locations and History. I had created the two tables using Code-First Approach from Visual Studio 2017 Package Manager Console. Due to some reasons, I had to drop the two tables. I deleted the two Models: Locations and History. Then I created a new Migration, following which I updated the database. On checking the Database from SQL Server Management Studio, I see that the tables are not there.
Now, I want to create the same two tables with some changes. When I am trying to add the tables to the database using Code-First Approach where I am typing the command update-database in the NuGet Package Manager Console, I get the following error:
Error Number:3701,State:5,Class:11
Cannot drop the table 'History', because it does not exist or you do not have permission.
However on checking in the database, I am not seeing the table. I even checked for the table by executing the select * from History query which gives results in
Invalid object name 'History'.
I feel that there is a mismatch between the Database and my Project. What to do?
I have deleted and modified somes tables in database sqlserver manually, then I have deleted __MigrationHistory table...
Now, when i run "add-migration" command, it regenare commands for recreate entire structure of database, but I want to syncronize the structure from the model to database, without recreates all tables in database...
the comnand "add-migration -ignoreChanges" is not correct, because the
model of website is different from database, because i have manual
modified somes tables.....
is possibles?
thanks
I have just installed symfony2 and I used this statement
php app/console doctrine:schema:create
When I see the database table, there is only one table and that is for my entity.
I can't see any base tables.
Is that normal??
It is absolutely normal. Symfony is a framework, it doesn't need any database tables. All settings for it are saved in configuration files which can be found in /app/config directory (application config files). And config files for bundles can be found in bundle_dir/Resources/config
Database is for your entities only. Have in mind that if you use "Doctrine Migrations", it will indeed create one database table called "doctrine_migrations".
The framework itself hasn't got any "base tables". It persists your entities only.
When I create any new database It automatically create some tables in new database.
Details:
I created a new database "TestDatabase" using below command
Create database TestDatabase
When I expand the Tables folder, I found that there are already some tables created automatically.
These are those tables which I was using in some other database.
Table names:
1. Employee
2. Admin
etc
How can I create new fresh database to make sure that no tables created in it?
Presumably at some point you accidentally created these tables in the model database.
This is used as the template for creating new databases. Simply delete them from model to stop them appearing in every freshly created database.
SQL Server uses the model database as the basis for new databases. Check and see if these tables exist in model - and if they do, delete them.
You should probably check for other objects in modeltoo (stored procedures, views etc).