What is the best practice for migrating a CakePHP 2 project that uses Views in MySQL to a CakePHP 3 projects that uses migrations. As I understand it, there is no support for Stored Procedures/Views in the Phinx library but I would like to continue accessing the View as if it were a table e.g appending conditions.
If there is no best practice then please outline the options that I would have available to me.
Related
At a conference yesterday, I learned about the importance of putting your database in source control. They showed us how to make a new Database project and import the database.
What I was wondering about is how I would change an existing project running on Entity Framework to utilize the database project's power?
Schema updates have always been done by using Entity Framework Migrations. I get that the Database project will be able to deploy database updates for me and save those update scripts to source control, but I would like to keep Entity Framework for querying my data (if that makes any sense at all).
Is it possible (or even: recommended) to use Entity Framework to access the database but manage the database using a Database project in Visual Studio ? How do you go about this?
I've tried searching for similar questions and using Google to find if anyone else is having the same problem, but no dice so far.
I should also state that I am considering using this in databases that also have stored procedures in them. These are not controlled through Entity Framework at all, and therefore are not in source control yet.
Thank you for your time.
What I was wondering about is how I would change an existing project
running on Entity Framework to utilize the database project's power?
Answer: I suggest you to see this course from Plural Sight : https://www.pluralsight.com/courses/code-first-entity-framework-legacy-databases
Is it possible (or even: recommended) to use Entity Framework to access the database but manage the database using a Database project
in Visual Studio ? How do you go about this?
Answer: Yes, it's possible and recommended. Your data project becomes the source of truth about the structure of your database. This is very powerful to keep control of all the changes and state of your database in one place (Visual Studio). The course from the first answer will teach you how.
I should also state that I am considering using this in databases that
also have stored procedures in them. These are not controlled through
Entity Framework at all, and therefore are not in source control yet.
Answer: I don't see any problem using stored procedures. The tool from the Plural Sight course will create the procedure in your source control and the reverse engineering will create a class/method for easy use of the proc.
I just came across the below alternative, which I didn't test though:
Generate Entity Framework Core classes from a SQL Server database project - .dacpac file
I believe this should be something to be considered
I developed an application like that, having 2 projects: application itself and the SSDT project for the database. The database changes were deployed via change scripts, and EF migrations were disabled in the application.
Everything worked fine, although it did bring a bit of an overhead. For example, it was a bit of a hassle to introduce major database updates / refactorings into the EF layer. For some reason, I was unable to reverse engineer database changes directly into the app, so I had to do it half-manually: creating new project, generate EF context for the entire database, and then copying new / changed files into the main application.
(Then again, it was almost 5 years ago. With luck, EF scaffolding has improved since then.)
I am using eclipse link jpa 2.0. I am using hana database. So I created views and generated java entity files using eclipse. The problem is, after starting Java Web application in Tomcat server 7, if any table data is modified, then view is not returning updated values. Even if I am running view with native query it is giving old values only.. please let me know what changes need to do in configuration level or entity creating level. ( I even added #Cacheable(false) also).
Assuming that when you say view you mean database views, perhaps the following existing answered question might help (though the link talks about Oracle instead):
Materialized View - Oracle / Data is not updating
You might be using some sort of materialized view made in the database that can be configured to refresh during certain events. In this case, the problem does not lie in Eclipselink's caching mechanisms, but in your database instead (as you mentioned that even native queries returned stale data).
I have a large number of CakePHP 2 web applications, many of them use remote data over the custom DataSource. I'm reading the documentation of CakePHP 3, but I can not find instructions for creating custom datesource.
My next project also requires a custom DataSource (ArangoDB), so I planned to build it with the new version of CakePHP.
Please do specify where and how to build a DataSource in CakePHP 3.
Thank You.
Just look at the code of any existing database driver and see how it is built? There is nothing in the book yet about how to create your own datasource.
ArangoDB seems to be yet another NoSQL DB, so take a look at how this Elastic Search datasource is done. By a quick look I think you can use it as a base for your implemention, they seem to be similar.
I was facing the same problem so I decided to write my own models in CakePHP 3.x. If you want you can use it from here. hope you like it.
I am trying to create multi-site platform using codeigniter.
Requirements are:
- Same Codebase.
- Same Database.
Just wanted to know how to achieve multi-site platform if we use same database/codebase?
Is there any way we can create separate tables for each new site i.e wordpress multisite?
Thanks a lot.
For separate sites you have to create separate directories, and set paths accordingly
eg.
application/contollers/site1/index.php
application/contollers/site2/index.php
Same for views and models
For database you can use prefix,
eg: if u are creating same site in different languages
eng_title
arabic_title
eng_description
arabic_description or arb_description
and you can fetch your desired data with your query and condition.
CI tutorial would be helpful for your requirements, please check
Running Multiple Applications with one CodeIgniter Installation
I'm working on project and need to implement custom database driver, but can't find any guidelines which interfaces i should to implement.
Is there any resourses available that could help writing custom driver rather thank just diving in code and trying to figure out how current drivers are implemented?
EDIT
By saying "driver" i mean support for example NoSQL dabase using standart Laravel's methods ( Eloquent model and Query builder ), for example:
User::take(10)->get();
For Mysql Laravel uses eloquent
laravel - eloquent
For NoSql like MongoDB, you can use laravel-mongodb
jenssegers - laravel-mongodb
It's even support Hybrid relations between MySql and MongoDB
I have worked on MongoDB (a NoSQL database) in one of my project, where I have to use a jenssengers package https://github.com/jenssegers/laravel-mongodb to use the functionalities. I was not able to use Eloquent in that.
Laravel - eloquent/ jenssegers - Laravel-MongoDB can manage hybrid relations as well.