Code Monkey home page Code Monkey logo

Comments (12)

nk9 avatar nk9 commented on May 16, 2024 9

Well, it's right there in the gist:

def include_object(object, name, type_, reflected, compare_to):    
    if type_ == "table" and name == 'spatial_ref_sys':
        return False
    else:
        return True

def run_migrations_offline():
    #[…]
    context.configure(# whatever generated params already exist, then
                      include_object=include_object)
    # […]

And the same for the other function.

from flask-migrate.

miguelgrinberg avatar miguelgrinberg commented on May 16, 2024 4

@renejahn yes, you can use the include_object configuration item in env.py: http://alembic.readthedocs.org/en/latest/api/runtime.html?highlight=include_object#alembic.runtime.environment.EnvironmentContext.configure.params.include_object.

from flask-migrate.

stefaang avatar stefaang commented on May 16, 2024 4

As the link doesn't work anymore, you may use this
https://gist.github.com/utek/6163250

from flask-migrate.

miguelgrinberg avatar miguelgrinberg commented on May 16, 2024 4

The updated location of the include_object documentation is: http://alembic.zzzcomputing.com/en/latest/api/runtime.html?highlight=include_object#alembic.runtime.environment.EnvironmentContext.configure.params.include_object

from flask-migrate.

miguelgrinberg avatar miguelgrinberg commented on May 16, 2024 3

I think your migration script has a drop table for spatial_ref_sys. This could be because this table is not represented by a model, so Alembic thinks you deleted it. You can just remove any references to this table in your migration scripts, and then Alembic will let it be.

from flask-migrate.

renejahn avatar renejahn commented on May 16, 2024 2

Even if this is closed....is there any way to exclude tables, so alembic won't add them to the migration scripts? I have just added postgis for a project and would be glad if I would not have to fix all migratescripts from now on?

from flask-migrate.

nk9 avatar nk9 commented on May 16, 2024 1

Just a note for anyone trying to get this to work: env.py has TWO functions which need to be modified to use your modified include_object: run_migrations_online and run_migrations_offline.

See this gist for an example of this solution implemented.

from flask-migrate.

nk9 avatar nk9 commented on May 16, 2024 1

It's not a matter of replacing the contents of the online and offline functions. You just need to add the appropriate code to ignore the table in both places. As @miguelgrinberg said above, you need to define an include_object function which excludes the table(s) in question. Then make sure to pass it as a parameter to context.configure() in both functions.

from flask-migrate.

mvexel avatar mvexel commented on May 16, 2024

Seems to be it -- this is a table that is auto-generated when you load the PostGIS extension in a db. Thanks.

from flask-migrate.

renejahn avatar renejahn commented on May 16, 2024

@miguelgrinberg Thanks! I will have a look at that.

from flask-migrate.

abhijithvijayan avatar abhijithvijayan commented on May 16, 2024

@nk9 Do I have to replace both the functions. Coz it seems like most of the code changed since the last time the gist was updated.

from flask-migrate.

abhijithvijayan avatar abhijithvijayan commented on May 16, 2024

Could you give a snippet for that? I already tried modifying it so many times and now I edit the generated script manually and remove the lines.

from flask-migrate.

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.