Git Product home page Git Product logo

Comments (4)

ruckus avatar ruckus commented on July 19, 2024

In the past I have needed to import sql files with stored procedures and I have done this in a migration up() method:

    $file = RUCKUSING_WORKING_BASE . '/database-objects/function_update_business_search_content.sql';
    if(file_exists($file)) {
        $contents = file_get_contents($file);
        $this->execute($contents);
    }

Adjust the path to suit your needs of course. In your case you could shell out to the "mysql" or "psql" commands if that approach makes more sense.

On Mar 15, 2013, at 9:25 AM, Andrew Colchagoff [email protected] wrote:

It would be really nice if I could specify a .sql file as a starting point for deployment. for example If I want to move an existing site over to ruckusing I would like to be able to do a database dump and then do migrations off of that. is there a way to do this?


Reply to this email directly or view it on GitHub.

from ruckusing-migrations.

acolchagoff avatar acolchagoff commented on July 19, 2024

This works for now, but it would be nice if I could include a var in the config file that points to a base sql file, which is used as a starting point to be run before all other migrations.

from ruckusing-migrations.

acolchagoff avatar acolchagoff commented on July 19, 2024

Ive found that this is trickier than I had hoped, I ran into a lot of trouble with line endings and the sort, this is the code I used when I finally got it to work.

    $file = RUCKUSING_WORKING_BASE . '/database-objects/database.sql';
    if(file_exists($file)) {
        $contents = file_get_contents($file);
        $queries = explode(";\n", $contents);
        foreach($queries as $query){
            if(!empty($query)){
                $this->execute($query);
            }
        }
    }

from ruckusing-migrations.

ruckus avatar ruckus commented on July 19, 2024

Yeah not to mention that if the file is large enough you will exist PHP memory in the file_get_contents call - think of like a many MB file will do.

One solution might be to somehow configure the path to the DB command line tool (mysql or psql) and then just shell out to that tool with the file path as an argument - just like how one would it manually / normally outside Ruckusing.

On Mar 26, 2013, at 9:45 AM, Andrew Colchagoff [email protected] wrote:

Ive found that this is trickier than I had hoped, I ran into a lot of trouble with line endings and the sort, this is the code I used when I finally got it to work.

$file = RUCKUSING_WORKING_BASE . '/database-objects/database.sql';
if(file_exists($file)) {
    $contents = file_get_contents($file);
    $queries = explode(";\n", $contents);
    foreach($queries as $query){
        if(!empty($query)){
            $this->execute($query);
        }
    }
}


Reply to this email directly or view it on GitHub.

from ruckusing-migrations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.