pum 1.2.2__py3-none-any.whl → 1.2.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pum/cli.py CHANGED
@@ -279,6 +279,11 @@ def create_parser() -> argparse.ArgumentParser:
279
279
  parser_baseline.add_argument(
280
280
  "-b", "--baseline", help="Set baseline in the format x.x.x", required=True
281
281
  )
282
+ parser_baseline.add_argument(
283
+ "--create-table",
284
+ help="Create the pum_migrations table if it does not exist",
285
+ action="store_true",
286
+ )
282
287
 
283
288
  # Parser for the "upgrade" command
284
289
  parser_upgrade = subparsers.add_parser("upgrade", help="upgrade db")
@@ -307,10 +312,13 @@ def cli() -> int: # noqa: PLR0912
307
312
  parser.print_help()
308
313
  parser.exit()
309
314
 
315
+ validate = args.command not in ("info", "baseline")
310
316
  if args.config_file:
311
- config = PumConfig.from_yaml(args.config_file, install_dependencies=True)
317
+ config = PumConfig.from_yaml(args.config_file, validate=validate, install_dependencies=True)
312
318
  else:
313
- config = PumConfig.from_yaml(Path(args.dir) / ".pum.yaml", install_dependencies=True)
319
+ config = PumConfig.from_yaml(
320
+ Path(args.dir) / ".pum.yaml", validate=validate, install_dependencies=True
321
+ )
314
322
 
315
323
  with psycopg.connect(f"service={args.pg_service}") as conn:
316
324
  # Check if the connection is successful
@@ -391,6 +399,17 @@ def cli() -> int: # noqa: PLR0912
391
399
  elif args.command == "restore":
392
400
  pum.run_restore(args.pg_service, args.file, args.x, args.exclude_schema)
393
401
  elif args.command == "baseline":
402
+ sm = SchemaMigrations(config=config)
403
+ if not sm.exists(connection=conn):
404
+ if args.create_table:
405
+ sm.create(connection=conn)
406
+ logger.info("Created pum_migrations table.")
407
+ else:
408
+ logger.error(
409
+ "pum_migrations table does not exist. Use --create-table to create it."
410
+ )
411
+ exit_code = 1
412
+ return exit_code
394
413
  SchemaMigrations(config=config).set_baseline(connection=conn, version=args.baseline)
395
414
 
396
415
  elif args.command == "upgrade":
pum/config_model.py CHANGED
@@ -72,7 +72,7 @@ class PumModel(PumCustomBaseModel):
72
72
  PumModel holds some PUM specifics.
73
73
 
74
74
  Attributes:
75
- migration_table_schema: Name of schema for the migration table.
75
+ migration_table_schema: Name of schema for the migration table. The table will always be named `pum_migrations`.
76
76
  minimum_version: Minimum required version of PUM.
77
77
  """
78
78
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pum
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: Pum stands for "Postgres Upgrades Manager". It is a Database migration management tool very similar to flyway-db or Liquibase, based on metadata tables.
5
5
  Author-email: Denis Rouzaud <denis@opengis.ch>
6
6
  License-Expression: GPL-2.0-or-later
@@ -1,8 +1,8 @@
1
1
  pum/__init__.py,sha256=P-NHd6_SYpk9aypefLI62QCZ3f5APOMCwSzrFFCKAew,759
2
2
  pum/changelog.py,sha256=yDc5swmMd5gb2vCEAlenoq5gs-ZEGc4uXicBtiGxkOk,3692
3
3
  pum/checker.py,sha256=GT2v7793HP1g94dv0mL6CHtQfblQwAyeFHEWCy44lkc,14379
4
- pum/cli.py,sha256=p5dMF4PyaM9iKpjd5QQATJLEZRiwhGDjB0oFElibwjE,14275
5
- pum/config_model.py,sha256=kwUkJ0lFdKyT3V0jJkRyWpI6JNHOqVTYfYKkm3B8v_Q,6884
4
+ pum/cli.py,sha256=HGt5_aqSk8hKdV3xYKNJFMEcZc_3BULWhvX-6wM_2EM,15046
5
+ pum/config_model.py,sha256=9jGuk8PC3JLS-VT7SNLF-WiVtaLZQi_24rPxt0zekTQ,6933
6
6
  pum/dependency_handler.py,sha256=AVeemsh6zUumRJKbRLRwP_FRC0x3K16TJiK2i9ogvn0,3861
7
7
  pum/dumper.py,sha256=EJZ8T44JM0GKgdqw1ENOfhZ-RI89OQ4DNdoTZKtLdEw,3404
8
8
  pum/exceptions.py,sha256=xyzzY4ht1nKfrVt59Giulflpmu83nJhxoTygrqiqPlw,1137
@@ -14,9 +14,9 @@ pum/role_manager.py,sha256=iEmznB09YAmmkIFh1Ar8nNdy-ZofO7R3J0VdjtLVyp8,10293
14
14
  pum/schema_migrations.py,sha256=rUn14aNkt8nw-69cCgklbtveanq6CrNdKKrc458cGIc,10491
15
15
  pum/sql_content.py,sha256=-0h3caJlvkyEjZwjPVrKh5ZYaDctC-5lklBvZ-zgRzA,10620
16
16
  pum/upgrader.py,sha256=h6a3Jeem6PQX-abWf7cBqYSaoSUXhuNBj6aYKrBxscM,6665
17
- pum-1.2.2.dist-info/licenses/LICENSE,sha256=2ylvL381vKOhdO-w6zkrOxe9lLNBhRQpo9_0EbHC_HM,18046
18
- pum-1.2.2.dist-info/METADATA,sha256=AbPA07FbZ3JFr8m5gnuLbmPhWmFPhCQ5_yoH8d588Y8,3138
19
- pum-1.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- pum-1.2.2.dist-info/entry_points.txt,sha256=U6dmxSpKs1Pe9vWiR29VPhJMDjrmZeJCSxvfLGR8BD4,36
21
- pum-1.2.2.dist-info/top_level.txt,sha256=ddiI4HLBhY6ql-NNm0Ez0JhoOHdWDIzrHeCdHmmagcc,4
22
- pum-1.2.2.dist-info/RECORD,,
17
+ pum-1.2.3.dist-info/licenses/LICENSE,sha256=2ylvL381vKOhdO-w6zkrOxe9lLNBhRQpo9_0EbHC_HM,18046
18
+ pum-1.2.3.dist-info/METADATA,sha256=GaGg7gKTmj86gLLDE6JBmYN2_a03kUMbVJWsdpTTP3g,3138
19
+ pum-1.2.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ pum-1.2.3.dist-info/entry_points.txt,sha256=U6dmxSpKs1Pe9vWiR29VPhJMDjrmZeJCSxvfLGR8BD4,36
21
+ pum-1.2.3.dist-info/top_level.txt,sha256=ddiI4HLBhY6ql-NNm0Ez0JhoOHdWDIzrHeCdHmmagcc,4
22
+ pum-1.2.3.dist-info/RECORD,,
File without changes