How do I keep developer's MySQL DB up to date with production? I have a slave copy of my production database that gets updated regularly. I cannot write to it, so I also have a developer copy of the DB. I would like to keep my developer copy up to date daily by running a stored procedure every morning to update yesterday's information.

Here's what I have so far:

CREATE DEFINER=`myName`@`%` PROCEDURE `spSyncMyDB`()
BEGIN

    DECLARE tableName VARCHAR(255);
    DECLARE primaryKey VARCHAR(255);
    DECLARE columnName VARCHAR(255);
    DECLARE dataType VARCHAR(50);
    DECLARE columnKey VARCHAR(255);
    DECLARE whereStatement VARCHAR(5000);
    DECLARE columnList VARCHAR(255);
    DECLARE currentSchema VARCHAR(255);

    DECLARE TableNameCursor CURSOR FOR 
    SELECT DISTINCT TABLE_NAME 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE DATA_TYPE IN ('timestamp', 'datetime')
        AND TABLE_SCHEMA = currentSchema
    ORDER BY TABLE_NAME;

    DECLARE ColumnNameCursor CURSOR FOR 
    SELECT DISTINCT COLUMN_NAME, DATA_TYPE, COLUMN_KEY 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = currentSchema
        AND TABLE_NAME = tableName
    ORDER BY COLUMN_NAME;

    SET currentSchema = DATABASE();

    OPEN TableNameCursor;

        FETCH TableNameCursor INTO tableName;
        SET whereStatement = '';
        SET primaryKey = '';
        SET columnList = '';

        OPEN ColumnNameCursor;
            FETCH ColumnNameCursor INTO columnName,dataType,columnKey;
            IF DATA_TYPE IN ('timestamp', 'datetime') THEN
                SET whereStatement = CONCAT(columnName, '&gt;= DATE(DATE_SUB(NOW(), INTERVAL 1 DAY)) OR ', whereStatement);
            END IF;
            IF COLUMN_KEY = 'PRI' THEN
                SET primaryKey = columnName;
            END IF;
            SET columnList = CONCAT(columnName,',',columnList);
        CLOSE ColumnNameCursor;

        SET columnList = TRIM(TRAILING ',' FROM columnList);

        IF LENGTH(whereStatement) &gt; 0 THEN
            DELETE currentSchema.tableName FROM currentSchema.tableName 
                LEFT JOIN currentSchema.tableName USING(columnList)
            WHERE CONCAT(whereStatement, currentSchema.tableName.primaryKey,' IS NULL') ;
        END IF;
        INSERT IGNORE INTO currentSchema.tableName 
            SELECT * 
            FROM productionSchema.tableName 
                LEFT JOIN currentSchema.tableName USING(columnList)
            WHERE CONCAT(whereStatement, currentSchema.tableName.primaryKey,' IS NULL') ;

    CLOSE TableNameCursor;

END


What do I need to do to get this working?
For the love of Fortran, stop what you're trying to do!

You should have all your database schema, stored procedures, etc checked into a version control system rather than only in the database.

If the database is only used with a single app, then you'd generally want to put the schema in the same repository as the application's source code, otherwise you should put the in a separate repository. Some version control systems like git makes it easy to work with multiple repositories like with git submodules.

This way the developer had just to run a script that drops the database and reloads the schema. When you need to make changes to the schema, you should write a database migration script. This way the developers can upgrade their own developments database at their own leisure, rather than having you breaking their code while they're in the middle of other works.