Create migration file while creating table in Laravel Voyager - database

I am using Voyager framework for Laravel. Wherenever I create table from Database Manager its creating table but its not creating any migration file. And its not good user interface who works on git repository(share the application's database schema). Everyone in the group has to create table in backend and have to work. This is not good.
but It creates table in database(phpmyadmin)
and we have option to create Model(while creating table)
Any solution? need quick response

Unfortunately, Laravel Voyager doesn't make migrations for user tables.
There are two workarounds.
Laravel Migrations Generator
Use this dev package to generate the migrations for the given tables. Availabe on GitHub at: https://github.com/Xethron/migrations-generator. View the documentation to see how to generate the migrations for the specific tables.
However, the collaborators will have to create the BREADs for them.
Copying the database
While sharing the database, the laravel voyager config tables that have all the changes and specs will be available on all the collaborator accounts.
Laravel voyager saves all its configurations in tables. Hence removing the need to generate migrations. Porting the whole DB works for most of my projects since I work on most apps alone.

Related

How to remove prisma models with data in production

I want to delete 2 models from a postgreSQL production database that are no longer used but have data on them.
I am a bit afraid of removing them from the schema and running prisma migrate dev and then having issues with the migration generated in production.
Therefore, my idea was to clean the database before:
1 make a query to the prod database to remove all the data from the tables related.
2 remove the models from the schema locally and run the migration.
3 push the migration to prod with the DB tables empty
What do you guys think?
Should I do that or just don't be afraid and delete the models locally + run prisma migrate dev and then push the migration to prod?
Are there any other ways to accomplish what I want?
Thanks in advance!
The approach you listed looks good.
Another alternative would be to delete the models from schema file and run npx prisma migrate dev command with the --create-only flag to just create the migration file without applying it to the database.
You can inspect the migration file first and if it looks good to you then you can invoke npx prisma migrate dev again to apply it.
Your plan seems a good one! This will ensure that the migration will not be affected by any data that is still present in the tables.
Another option you could consider is to rename the tables in the database, rather than removing them entirely. This will allow you to retrieve the data later (if necessary), but it will also allow you to remove the models from your schema without any issues.
So I would do this:
Rename the tables
Remove the models from the schema locally
push the migration to prod
Remove the renamed tables from step 1.

How do I relate tables in Azure Mobile Service - Javascript Backend

On the azure page I can create my tables but there are only 4 data types and no option to create or relate the tables using foreign keys and SQL.
What I want to do is have a user and contact table with userId in contact table as a foreign key.
I am using apache cordova and angularJs on the front end in visual studio. I have already added the mobile service to my project.
Mobile Services does not directly support relationships in the backend, but you can customize the data using server scripts and the mssql object. Alternatively, you can create database views that have relationships between tables.
For an example of mapping relationships using database views, please see my post in this forum thread: Best Practice For Syncing Related Tables in Offline Mode.
For more information on managing the database directly, see this article: Scale mobile services backed by Azure SQL Database.

Does CakePHP make tables in database when installing?

It's my very first time installing and using CakePHP on localhost. I've accomplished all the steps that are required in order to install CakePHP. After installing I checked my database and it is not showing me any tables in my database. Is something wrong or does CakePHP not insert any tables while installing?
Below is my status of CakePHP:
Your version of PHP is 5.2.8 or higher.
Your tmp directory is writable.
The FileEngine is being used for core caching. To change the config
edit APP/Config/core.php
Your database configuration file is present.
Cake is able to connect to the database.
CakePHP: the rapid development php framework (default) 0 query took
ms Nr Query Error Affected Num. rows Took (ms)
No, there is nothing wrong. CakePHP doesn't create any tables for you because it cannot know what tables your application will use.
You can use the Bake console to setup and create the database after the basic installation. See http://book.cakephp.org/2.0/en/console-and-shells/code-generation-with-bake.html
A typical Cake workflow is
Create your tables following Model an database conventions
Generate the application code using bake
Refine the application

How to use the example membership module from MVC4 with codefirst created database?

I'm working on a MVC4 project with MS SQL Server Express database.
Here is what I did:
I started a MVC4 project in which the membership module is included (AccountsController.cs, AccountModel.cs and view files)
Next I added some models, controllers, a context and an initializer to seed some test data. Using ef-codefirst, this created my context.mdf database which works fine.
The problem I'm having is that I now have 2 databases. The one from the standard membership module, and the one created with ef-codefirst.
I cannot seem to find out how I can use the membership module, to work with the database that is created from my ef-codefirst because I need everything to be in 1 database.
I've been searching all day for examples or a solution in which the ready to go membership module from the mvc4 template is used in combination with a code first created database but after all these hours I lost track of what to do and what not to so hopefully anyone got some tips.
So after another week of stress the problem I was having turned out to be because of Migrations.
With migrations enabled you can only use 1 database context class.
I started out without migrations, then created the database tables with EF and seeded data to them with an initilizer. Next I added migrations, added everything from my own context to the existing context from the template membership module and then nothing worked anymore. Migrations wasn't creating any tables or modifying any.
So I started a new project, with only 1 context class and migrations, and everything worked fine.

ASP.NET MVC Code-First EF - Possible to use EF without database create permissions?

So I'm working on an ASP.NET project for university. We have to upload our code to a server running IIS and SQL Server 2008. I've written my project using MVC Code-First EF. I understand that the Entity Framework system needs permission to create the database to work properly (you can't just give it an empty database and let it fill it with data). This has created a problem for me since I do not have database creation privileges on the shared SQL Server. Is there any way around this?
As you don't have permissions, it sounds like you'd need to get a DBA to create your database on the server you are trying to deploy to - this could be done from either a database creation script or from a database backup of the db on your dev machine. You can then instruct EF code first not to try to create / update the database automatically by adding this line to your global.asax (or indeed anywhere before you first access the database)
Database.SetInitializer<YourContextType>(null);
You can use an existing database, rather than let EF create one for you. I have done this myself, but admittedly only when using EF Migrations. Otherwise, you run into trouble with missing table exceptions and what not.
When using migrations, just point your connection string to your empty database, create an initial migration to populate the database with your schema and then update the database itself.
See this answer: How do I create a migration for an existing database in EntityFramework 4.3?
.. which include this nice link to getting started with EF Migrations: http://thedatafarm.com/blog/data-access/using-ef-migrations-with-an-existing-database/
All this is available through Nuget, and if you have access to Pluralsight content, I can highly recommend Julie Lerman's video on the topic.
If you don't want to use Migrations, you can still use Code First if you just create the database objects manually using SMMS, but obviously you have the manual work of keeping your model and the database in sync.

Resources