How to add more tables to Magento database Schema? - database

We have an issue with respect to adding tables to Magento Schema.
Problem: we have a 3rd party custom built ERP system, which we need to integrate with up coming Ecommerce soltuion.
We want to create few tabels, whose table structure is exactly the same as the ERP one. This is planned for our future sync process with the ERP related to the products, inventory ..etc
But we don't know
how to create these tables in Magento...? Or
whether Magento allows to create additional tables ?
If we can create, what changes does it causes that we need to be sure ?
Please if anyone in the community has answers to any of the questions that we have, please let us know.
Thanks in advance
Kiran

Too broad There is no such thing to create tables in Magento unless you mean creating them directly in the DB.
Maybe you should take a look to the import/export functions in magento to integrate to your ERP or even better the web services (SOAP, XML-RPC) api.

Related

Designing databases and applications for hosted / cloud solutions

Are there any resources available that can guide someone on how to 'think' about the various components of a hosted / cloud solution before going ahead and starting to make a hosted application? If that made no sense, what I mean to ask is are there any guidance books/websites on what things need to be considered when making a cloud application?
I am attempting to make a hosted CRM-style software application that will serve many hundreds of customers. The application is powered by a SQL server database with many tables and a ColdFusion, HTML5, CSS, Javascript front-end. If I was installing this application and its components at each client site, then each installation is unique to that customer. But somehow I have to replicate this uniqueness in the cloud which is baffling me.
Only two things have come to mind so far:
The need for a unique database per customer in SQL server
The need to change DB connection strings per customer in the web application
My thought process has come to a block when I am trying to envisage how to design the application to serve so many different customers. Even though the application that all customers use will is the same (same DB tables, same front-end), the data that they store and retrieve will be specific to them. So I was thinking that surely each customer needs a separate database creating for them? Is it feasible to create a replica database for each customer? If I need to update some tables or add a new table, how would I do this for hundreds of different databases?
From the front-end I guess each unique customer log-in would change DB connection strings so that they can only access their database. Other than this I can't think of anything else that needs to change per customer basis.
When a new customer wants to sign up, it needs to be clear to me what I need to create for them to have access to the application. I guess this is ultimately what I need to think of but I'm stuck.
If anyone can suggest some things to think of or if there is a book or website on this kind of thing that someone could point me to I'd really be very thankful.
EDIT:
I was looking at an article about Salesforce.com and it says
"In order to ensure privacy of data for each user and give an effect of each having their own database, the data from different users are securely isolated from one another."
Anyone know how this is achieved or how it may be done?
Found some great information here. It is called multi-tenant database design and seems to be a common topic. Once I get the database designed then the application can sit nicely on top.
https://dba.stackexchange.com/questions/1043/what-problems-will-i-get-creating-a-database-per-customer

Using flyway to support multiple database instances with various data

My team currently has several beta customers using our product. The current method of upgrading a customer's database to the latest version consists of, re-initializing the database, and re-creating the customers configuration by hand, which isn't a lot, but is certainly tedious and will change as we implement some kind of migration strategy.
My question is, is it possible to use flyway (or some other tool) to manage database schema migrations of all instances of our product, yet retain independent instance data? What is the best approach to this kind of problem.
Yes, you can use Flyway for this.
You can place the customer-specific reference data in a separate location per customer.
You can then configure flyway.locations like this:
Customer A: flyway.locations=scripts/ddl,scripts/data/customer_a
Customer B: flyway.locations=scripts/ddl,scripts/data/customer_b

magento - migrate sales tables

I need to transfer sales tables form an old magento database to a new one
How can i do that without deleting the records from the new database and which are the sales tables
Given how complex Magento's schema is, I would advise against directly writing into the database. If you still want to do it there is this article that might help you understand the process as well as all the tables involved. Generally speaking the tables are prefixed with 'sales_'.
Since Magento's core import/export functionality is limited to Products and Customers, your best option is probably to look for an extension that will do this, or write your own. Here is another question on SO that is related to this, providing a link to some paid extensions that do this.
The sales ID's shouldn't conflict, assuming you do intend to transfer your customers as well since there may also be new that correspond to the sales. To keep this simple and short, which this process really is once you know which tables to export, you do the following:
Export all customer_ and sales_ tables (these may have a prefix, and will look like something like yourprefix_customer.
Then, you make sure that the last orders ID is updated in the eav_entity_store table, to make sure that Magento created new orders with the correct ID's. You would do the same for the other 3 rows within eav_entity_store which are for invoices, shipping and creditmemos.
Here more detailed tutorial on this topic if needed.
I strongly recommend use a plugin for that situation.
This free plugin worked for me, just install through Magento Connect and then (after refresh cache) you'll see "Exporter" tab on menu with option for import and export.

django manual database migration

I am preferring to manually migrate my tables in Django. Because using automated tools puts me in a place where I cannot see the impact. With impact, I mean the the time it takes the db get in synch with my models. Below is a simple example:
class User(models.Model):
first_name = CharField(..)
Let's say I want to add this:
class User(models.Model):
first_name = CharField(..)
last_name = CharField(..)
I will follow the these steps in my production server:
Disable site traffic.
Manually connect to the your DB server, let's say MySQL and add a field to the User table named last_name (make sure it is sync with the SQL generated for the new Model, of course.)
Update your model.
Upload new files, restart traffic.
I have two questions for this scenario:
Is this a preferred/acceptable way for manual db migration in Django?
If I just add a field with a specific default value to the User table by SQL manually, but don't update the model, will I still get DatabaseIntegrity exception?
Thanks in advance,
With all of the schema migration tools, such as south, there are ways of explicitly defining how your models get migrated. The benefits of using a tool such as this are:
Your migrations are stored in your version control system
There's a documented procedure to roll back schema migrations
If another developer joins your project, you can refer that person to the south documentation rather than explaining your own hacky solution to documenting schema migrations.
I think I should just emphasize a point here: Though south has automigration tools, you don't have to use automigration if you're using South.
Is this a preferred/acceptable way for manual db migration in Django?
I would answer no. As #Mike said Django has a reliable and fairly versatile ecosystem of migration tools, the most prominent of which is South. #Mike's answer has the details right.
To answer your second question:
If I just add a field with a specific default value to the User table by SQL manually, but don't update the model, will I still get DatabaseIntegrity exception?
No. Your models will continue to function normally. Of course if you want to do something with the new fields using Django's ORM you'll be better off adding them to the model class.
A side effect of this is that you can migrate legacy database tables by selectively choosing the fields to use in your models.

Umbraco Database Question- Adding custom tables

I'm working on a site managed by Umbraco. I need to store data about images and clients. I don't think there is any way I can store that data in the existing tables.
Is there any reason I shouldn't add the tables I'll need to the Umbraco database, rather than creating a separate DB? I like Umbraco so far but the documentation is a little thin and I haven't found any suggestions one way or the other.
TIA
I have built a site using Umbraco, with a separate application with a database of vehicles. I used the same database as Umbraco is using, and prefixed all my custom app tables with a few letters to distinguish them easily (eg: vehicles_xxx)
I have had no problems with this arrangement, and don't believe there's much risk involved. Of course you'll need to take care when upgrading Umbraco (never upgrade in the live environment before fully testing, and preferably do it locally anyway), however its unlikely an upgrade script will ever alter or delete any tables that it does not know about.
There's heaps of doco available for umbraco now - much more than when i started.. however a question like this is always best for the forums. :)
all the best
greg
You might use the Umbraco API to store and retrieve your data and enjoy the ease of not having to worry bout tables and much more. Or you create your own tables. Do as Gregorius says - using umbraco db is fine.
Your choice depends on:
do you have a lot of data?
do you have a large relation model?
If not - then go with Umbraco API
The rest of the answers you'll find on http://our.umbraco.org
/Jesper Ordrup

Resources