Git Product home page Git Product logo

simple-db-migrate's People

Contributors

andrewsmedina avatar cyberelfo avatar dependabot[bot] avatar gabrielfalcao avatar guilhermechapiewski avatar hltbra avatar ichernev avatar ricobl avatar sh0nk avatar thulio avatar wandenberg avatar wesrog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-db-migrate's Issues

Feature request: skip on SQL error.

If migration file causes an SQL error (for example column already exist), and we still continue with the rest of migration files? That could be optional parameter (such as --continue-on-error).

BUG: db-migrate does not search for config file

This bug was found in version 1.5.3 but is likely in the new version as well. Steps to reproduce:

In a new project directory, install simple-db-migrate and create an example file named "simple-db-migrate.conf" with valid settings. The following command succeeds just fine:

$ db-migrate --config="./simple-db-migrate.conf" -n foo_migration_name

However if the --config directive is removed, the command fails:

$ db-migrate -n bar_migration_name
[ERROR] invalid key ('database_migrations_dir')

It seems obvious that the db-migrate command is not picking up the default config file name, as specified in the help:

--config=CONFIG_FILE
                    Use a specific config file. If not provided, will
                    search for 'simple-db-migrate.conf' in the current
                    directory.

Installation failure in python 3.8

Installation fails in python3.8.

$ docker run -it python:3.8 /bin/bash
root@4f07de037284:/# python --version
Python 3.8.2
root@4f07de037284:/# pip install simple-db-migrate
Collecting simple-db-migrate
Downloading simple-db-migrate-3.0.0.tar.gz (42 kB)
|████████████████████████████████| 42 kB 402 kB/s
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-k6peapnk/simple-db-migrate/setup.py'"'"'; file='"'"'/tmp/pip-install-k6peapnk/simple-db-migrate/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-k6peapnk/simple-db-migrate/pip-egg-info
cwd: /tmp/pip-install-k6peapnk/simple-db-migrate/
Complete output (21 lines):
/tmp/pip-install-k6peapnk/simple-db-migrate/simple_db_migrate/main.py:136: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if destination_version is not '0' and not (self.db_migrate.check_if_version_exists(destination_version) or self.sgdb.get_version_id_from_version_number(destination_version)):
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-k6peapnk/simple-db-migrate/setup.py", line 4, in
setup(
File "/usr/local/lib/python3.8/site-packages/setuptools/init.py", line 144, in setup
return distutils.core.setup(**attrs)
File "/usr/local/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python3.8/distutils/dist.py", line 982, in run_command
log.info("running %s", command)
File "/usr/local/lib/python3.8/distutils/log.py", line 46, in info
self._log(INFO, msg, args)
File "/usr/local/lib/python3.8/distutils/log.py", line 31, in _log
stream.write('%s\n' % msg)
File "/usr/local/lib/python3.8/codecs.py", line 378, in write
self.stream.write(data)
TypeError: write() argument must be str, not bytes
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
root@4f07de037284:/#

Resetting the migration to old ones

 /usr/local/bin/db-migrate 20150721105731 --force-old-migrations --config="sample_simple-db-migrate.conf"
- Current version is: 20151216191128
- Destination version is: 20151216191128

Nothing to do.


Done.

I can't get back to previous migrations.

Does simple-db-migrate support adding stored procedure?

In order for SP to work, I will need to set DELIMITER and the simple-db-migrate parser parses the string by ";" which won't work.
Also, it gives syntax error, even I put
DELIMITER$$
by itself in the script.

simple_db_migrate.core.exceptions.MigrationException: error executing migration: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER$$' at line 1")

[ERROR DETAILS] SQL command was:
DELIMITER$$

Package is out of date, doesn't work with python 3

It looks like you all added python 3 support with this commit: 8e72149

However, when I install the package with pip, it looks like this code is not present.

Downloading simple-db-migrate-2.2.0.tar.gz (41kB)
  Complete output from command python setup.py egg_info:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-udo31o1j/simple-db-migrate/setup.py", line 2, in <module>
      import simple_db_migrate
    File "/tmp/pip-build-udo31o1j/simple-db-migrate/simple_db_migrate/__init__.py", line 95
      except Exception, e:
                      ^
  SyntaxError: invalid syntax

Backslashes stored incorrectly in __db_version__

The backslashes get unescaped twice before entering the database.

For example, if I have
INSERT INTOtableNameVALUES('\\\\my\\\\namespace');
then it will enter db_version.sql_up or sql_down as
INSERT INTOtableNameVALUES('\my\namespace');

This is especially problematic if backslashes appear in sql_down, as running with --force-files will cause different queries to be executed even when there are no changes to the migration file.

db-migrate skiping sql's which are older than last one executed

Example:
I have 4 SQL to execute:
20150112144707_sql1.migration
20150112144709_sql2.migration
20150112144710_sql3.migration
20150112144711_sql4.migration

ON first deployment only 3 of migration were added to master branch, so lets say 20150112144710_sql3.migration was not added.

Migration folder were looking like this:
20150112144707_sql1.migration
20150112144709_sql2.migration
20150112144711_sql4.migration

On next deployment 20150112144710_sql3.migration was added.
So, migration folder was looking like:
20150112144707_sql1.migration
20150112144709_sql2.migration
20150112144710_sql3.migration
20150112144711_sql4.migration

But, as 20150112144711_sql4.migration was already executed and it is younger than 20150112144710_sql3.migration db-migrate did ignore 20150112144710_sql3.migration

Can it be fixed?
How do you handle this situations?

BUG: port number default no longer works

@wandenberg this is an issue in version 1.6.0

The db-migrate command now seems to require a DATABASE_PORT setting to be explicitly defined in the configuration file, rather than automatically defaulting to 3306 in absence of a setting.

If this setting is not defined, then the command fails with:
[ERROR] could not connect to database: an integer is required

Migration not able to handle hindi text

I have create a .migration file which contains hindi text. db-migrate command fails when I run it.

[ERROR] error logging migration: (1366, "Incorrect string value: '\xE0\xA4\xB6\xE0\xA5\x81...' for column 'sql_up' at row 1")

[ERROR DETAILS] SQL command was:
20190313161739_user.migration

Migration file:
CREATE TABLE users
(
id INT UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
name VARCHAR(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO users (id, name) VALUES (1, 'Rajeev'), (2, 'राजीव');

Tag de versão inconsistente

Uma migration foi executada mesmo estando com 1 character a mais no timestamp.

Exemplo : 201112152000000_associando_comentario_a_galeria.migration
o timestamp : 2011-12-15 20:00:000

SSL/TLS support

I'm trying to upgrade a MariaDB database on Azure and it has the SSL enforcement enabled.

Simple-db-migrate fails with the following error:
[ERROR] could not connect to database: (9002, 'SSL connection is required. Please specify SSL options and retry.')

It would be great to be able to pass the SSL options to the driver. They could be stored in the config file for instance like the other parameters.

Type error in python 3.6

I get an error when I run migration in python-3.6

Traceback (most recent call last):
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/__init__.py", line 92, in run
    Main(config).execute()
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/main.py", line 50, in execute
    self._execution_log('\nStarting DB migration on host/database "%s/%s" with user "%s"...' % (self.config.get('database_host'), self.config.get('database_name'), self.config.get('database_user')), "PINK", log_level_limit=1)
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/main.py", line 254, in _execution_log
    CLI.msg(msg, color)
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/cli.py", line 243, in msg
    print("{}{}{}".format(cls.color[color], msg, cls.color["END"]))
  File "/Users/rajeev/Workspace/procure/procure-backend/bin/../lib/python3.6/codecs.py", line 377, in write
    self.stream.write(data)
TypeError: write() argument must be str, not bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rajeev/Workspace/procure/procure-backend/bin/db-migrate", line 11, in <module>
    sys.exit(run_from_argv())
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/__init__.py", line 18, in run_from_argv
    run(options.__dict__)
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/__init__.py", line 96, in run
    CLI.error_and_exit(str(e))
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/cli.py", line 233, in error_and_exit
    cls.msg("[ERROR] %s\n" % msg, "RED")
  File "/Users/rajeev/Workspace/procure/procure-backend/lib/python3.6/site-packages/simple_db_migrate/cli.py", line 243, in msg
    print("{}{}{}".format(cls.color[color], msg, cls.color["END"]))
  File "/Users/rajeev/Workspace/procure/procure-backend/bin/../lib/python3.6/codecs.py", line 377, in write
    self.stream.write(data)
TypeError: write() argument must be str, not bytes

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.