create symfony1.2 existing project new module? - symfony-1.2

If i create new module in existing project the table is not create and display in command line Application frontend not exist message display

not sure i understand properly your problem; when you create a module, it doesn't create a table (i.e. a database table); it only creates a directory within the modules/ folder of your app (for example frontend/modules); within this directory, it creates an actions folder containing the actions.class.php file, as well as a templates module.
When you want to alter your database, it depends whether you're working with propel or doctrine.
For example, using Propel, what you do is :
you update your tables and columns definitions in config/schema.yml;
you run the following scripts :
symfony propel:build-model (creates the classes);
symfony propel:build-forms (creates the forms related);
symfony propel:build-filters (creates the filters);
symfony propel:build-sql (creates the new complete SQL file, with the new tables);
symfony propel:insert-sql (process the SQL file in your DB — Be aware that it overrides your actual database; if you already have data you wish to save, i recommend that you manually add the tables in your database).

Related

Prestashop 1.7: Can I use another database just for executing a side script?

I have created a Prestashop website with a database N°1. For some reasons, I want to write a script, that I'll execute a few times and that will simply fill a database N°2 with some data. This script has nothing to do with my Prestashop website, but is part of the same project and then, must be hosted in the same server, and moreover must be present within the Prestashop website's files (under a module directory I've made).
My question is: is it possible to use this database N°2 (only for this script)? Can I use Prestashop's Db.php class to do it?
Don't hesitate to ask for more informations if I'm not clear.
So if i am reading your post correctly you want to create two databases.
For example "prestashop_n1" and "prestashop_n2".
prestashop_n1 contains all prestashop required tables.
prestashop_n2 contains data extracted from prestashop_n1
In order to extracted data from prestashop_n1 to prestashop_n2 you could write a module.
In this module you can create a database connection to database prestashop_n2
You can use PHP to copy data from prestashop_n1 to prestashop_n2
Alternative you can add a cron-job to execute your script for copying data x times a day.

Entity Framework DB Migration Script

Okay, so this is my situation. I have generated POCOs from a db and developed around them. I have also renamed and changed some of these POCOs to be more readable. I have now made changes to my original db scheme and need to migrate the changes back to my models without overriding my changes except where the scheme has changed. It there a way to generate a *.sql script to hand to by DBAs? If so, it there a way to compare two dbs and generate a change script? ie - dev db => prod db.
You can switch a project to code first and generate the scripts you need via migrations. See the link below for a guide on moving from db first to code first, but it sounds like you may be partially there already.
1) enable-migrations for the project with your context if you haven't already.
2) create a baseline migration. EF will use this as a starting point so you won't get a bunch of code to create the objects that already exist. The ignore changes flag tells EF not to create the existing objects. https://msdn.microsoft.com/en-us/data/dn579398.aspx?f=255&MSPPError=-2147217396#option1
create-migration InitialCodeFirst -IgnoreChanges
3) Now modify your schema as you normally would and create a migration:
add-migration SomeNewThing
4) Create a script for a different database (like PROD) by using -Script. This will not update your database it just creates a script, so I usually run it a second time without -Script:
update-database -Script // creates a script (in VS), but does not apply
update-database // updates the database your connect string points to
5) DBA runs script and this will add a record to __MigrationHistory to identify it as being applied.
http://devgush.com/2014/02/24/migrating-a-project-from-database-first-to-code-first/
Here is a useful link on deployment: http://cpratt.co/migrating-production-database-with-entity-framework-code-first/#at_pco=smlwn-1.0&at_si=54ad5c7b61c48943&at_ab=per-12&at_pos=0&at_tot=1

Any easy ways to automate creation of Yii DB migration code

I have started using Yii (1.1) in order to keep syncronized db schemas between different environments.
My questions is: are there any easy ways to automate the writing of the Up() and Down() methods with SQL code?
At the moment, if I add a new table or alter an existing table I need to write manually these methods.
The command yiic migrate create table_name only creates an empty class.
Alternatively I could create the new migration file and use the $this->exexute('sql code here') property. But I was just wondering if there is any way for Yii to detect the db changes and create the migration code on it's own

Deploying Database Project

lots of confusion for me while handling the VS Database Project. Okay, while trying to deploy the DB Project to a target database, the objects (SPs, Triggers) still refer to the previous database if included the reference of the same database in the objects. For example:
I have an SP which contains one of its table reference as DBName..TableName. After I deploy my project to a target database with a new name, the object still refers to the same DB which is DBName. Now to make my deployment work I change this hardcoded name to $(DBName) variable and this is passed along as the variable while deploying the Databases to the target DB. This gives an error while deployment. So can we deploy the database project containing cross references or references to the same DB to the new database target and get these names changed altogether.
Just try the "Publish..." Command from the Database Project Property Menu (right click on the project in solution explorer). Once the dialog is open you can set the values for your variables (e.g. [$(MyDatabase)]. If you choose the "Create publish script"-Option, a script will be generated containing SQLCMD-Variables which can be set to your target database.

SQL table not created when deploying a WAR file to Liferay

I've created a JSR-268 portlet for Liferay which uses services to interact with a database. I can deploy the portlet without problems or errors, but the table defined by the services is not created!
I get no "table not found" error when I test the portlet. I get no errors at all! The table just isn't there in the database. I've found other things on the internet saying that I should use the generated "create.sql" file that the Liferay Service Builder created, but I don't see that file anywhere.
Can someone help me out?
Have the tables never been created? I had a similar problem when I deleted the tables by hand. I thought they would be created again when deploying the portlet again, but it didn't happen.
After studying the source code I found out that Liferay stores information about the portlets in the table servicecomponent and checks 2 things before it executes the (pseudo) SQL in META-INF/tables.sql:
The build.number in service.properties must be higher than that, stored in servicecomponent,
The tables.sql must be different from the one stored in servicecomponent.
Only then the tables.sql is executed.
An easy way to achieve that, is to delete all entries in servicecomponent addressing your portlet.
Try by deleting an entry from servicecomponent table. And redeploy your portlet.
delete FROM servicecomponent where buildNamespace="<your table namespace>"
I have faced the same problem and below given solution works for me.
Steps
I have changed the build.number in service.properties higher than that stored in servicecomponent.
Removed all the xml files from META-INF folder.
Removed all the sql files from webapp/WEB-INF/sql folder.
Then build-service and deploy will creates custom tables that are defiend in service.xml file.
If you're using serviceBuilder in Liferay 6.2 when you define a new entity in the Liferay schema in service.xml, the first time that any Portlet tries to access the table it will be created if it's not exist.
There are several problems when you're using a different schema because sometimes Liferay not create tables automatically. Then you need to lauch the Creation SQL sentence and create it manually and then access it through LocalServiceUtil.