Create a view in database as migration with Cakephp3 - database

Does anyone knows how to create a view in database with CakePHP3?
Is there a way to do this with migrations?
Like define a view to being executed then when I run cake/bin migrations migrate this create view in BD. Than this may create a view and I must be able to execute this view whatever I want in models or controllers?
Thanks for your help in advance

As markstory said in this issues on GitHub this, functionalities didn't exist ye and may be released soon:
https://github.com/cakephp/cakephp/issues/11632
https://github.com/cakephp/migrations/issues/347

Related

How does Entity Framework know which migration to add?

I am trying with the help of Entity Framework to set up this without having to deal with the code-related part of SQL.
I created a model and added a migration via package manager console and it all worked well it updated and created the table.
The thing I want to ask is how does the entity know which migration I want to add.
I used:
add-migration (and put here the name of the migration file)
But the thing I don't understand is how does it know which model I want for my table?
Or put it in other words if I would have 2 models before I did any migrations which model would get chosen?
Would really appreciate it if someone could help me out.
Thanks in advance
Seems you are using entity framework migrations and got confused how it works. Here is the explanations:
Question: But the thing I don't understand how does it know which model I want for my table?
If you look into your project folder there is the directory
Migrations. Inside it all the migrations history logs written
into.When we made any changes on data model, EF Core compares the current model against a snapshot of the old model to determine the
differences, and generates migration source files; the files can be
tracked in your project's source control like any other source file.
Once a new migration has been generated, it can be applied to a database in various ways. EF Core records all applied migrations in a
special history table, allowing it to know which migrations have been
applied and which haven't
Question: If I would have 2 models before I did any migrations which model would get chosen?
As said earlier, as it keep track previous migrations history, so in your old model it compares the differences and overrite latest
changes that were not written on older files. This is how it works.
Hope above explanations guided you accordingly and redeem your confusions. You can also have a look on official documents here

My typeorm migration:run get done but dont create the tables

im working on a project that i used the mongodb, so i started the database and used the docker, every configuration are ok, but whe i put the command "yarn typeorm migration:run" it get done, but dont create the tables with all the migrations in my project, anyone can help me with this?
my ormconfig looks like thisenter image description here
that's how the console become when i use the comm
enter image description here
There is no need to migrate when you use mongdb with typeorm.Just define models, it will automatically create database table schemes based on your models.
Add synchronize: true,
to your ormconfig and it will auto-create all tables from your entities on connection.

SymmetricDS synch from view

I'm looking at the features of SymmetricDS (last version symmetric-server-3.7.24) and in their forum I read it is actually possibile to synch from a view.
So I tried to synch from a view but when I run the program I got an error because symmetricDs cannot create a trigger on the view.
I also read that if a use a materialized view, then the trigger should be created.
The view is on a sqlserver 2008. I dropped the view and create a new one with schemabinding and add a cluster index on it. I also check that all the options are set as required in the MSDN guide to create indexed table.
I run symmetricDS again but still fail to create the trigger on the view.
Can anyone help me?
If what I ask is actually not possibile, then it is possibile to craete an extension that does not use trigger to synchronized the tables? I don't care that the two db are synched realtime, I can use a scheduled job, it will be just fine.
Thank you for you help and suggestion.
BTW: I can also change tool you you know a better one :)
I don't think that's a supported use case. However, you can try setting the sync_on_insert/update/delete fields to 0 on the sym_trigger. Then you would be able to sync the view with an initial load or by scheduling reloads (see "symadmin reload-table" command).

How to create a Controller in CakePHP without setting up database tables?

I am very new to cakePHP but I am a bit knowledgeable with Ruby on Rails. I tried creating a controller using the cake bake command in the console but it said:
Your database does not have any tables
As far as I can remember in rails, it allowed me to create controllers without tables or even without setting up database. What I am trying to do is that I want to create a controller and a view for pages such as Home, About, and Help. I don't think those pages still need a model or a database table. Pls help.
sure you can create controllers and views... even models without tables.
But you can't bake them =D bake is just to read the database and help you create your classes from there. So if you dont have any table, you dont have anything to bake..
For the static pages such as Home, About and Help you could use the PagesController
Cheers!

Is there any way to access a datasource from one project, in another project?

I have access to a database table that has been added as a datasource in project (A). Is there any way to refer to this database table from project (B) WITHOUT adding it to project (B)'s datasource?
i.e.
ProjB.databasetable.GetDataSetSchema
Any ideas would be really appreciated. Thanks guys!
The database table is not related to the project A in any way. The project A contains a datasource, probably a DataSet, that is used to access the table.
If you would like to reuse that dataset, just add a reference to ProjectA to ProjectB and ProjectA.MyDataSet will be there for you to use.
The way is to use remote data server and all application will connect to your server.
You can make this with DataAbstract
but you need to rewrite your application.

Resources