<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Migration scripts for distribution, embedded in library in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/migration-scripts-for-distribution-embedded-in-library/m-p/37346#M26327</link>
    <description>&lt;P&gt;I'm working on a python package that can be installed via pip. The package will manage a delta table for the user, and new versions of the package may need to run migrations on this table&lt;/P&gt;&lt;P&gt;Is this an okay format to use?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def migrate(table_path):
    mm_path = f"{table_path}/_migration_marker"
    marker = 0

    try:
        marker = int(dbutils.fs.head(mm_path, 10))
    except Exception as e:
        if "java.io.FileNotFoundException" in str(e):
            print("Migration marker not found")
        else:
            raise e

    if marker &amp;lt; 1:
        sql = f"""CREATE TABLE catalog.schema.tablename ... LOCATION {table_path}"""
        spark.sql(sql).count()
        marker = 1
        dbutils.fs.put(mm_path, marker, True)

    if marker &amp;lt; 2:
        sql = f"""ALTER TABLE catalog.schema.tablename ..."""
        spark.sql(sql).count()
        marker = 2
        dbutils.fs.put(mm_path, marker, True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2023 01:43:47 GMT</pubDate>
    <dc:creator>matty_f</dc:creator>
    <dc:date>2023-07-11T01:43:47Z</dc:date>
    <item>
      <title>Migration scripts for distribution, embedded in library</title>
      <link>https://community.databricks.com/t5/data-engineering/migration-scripts-for-distribution-embedded-in-library/m-p/37346#M26327</link>
      <description>&lt;P&gt;I'm working on a python package that can be installed via pip. The package will manage a delta table for the user, and new versions of the package may need to run migrations on this table&lt;/P&gt;&lt;P&gt;Is this an okay format to use?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def migrate(table_path):
    mm_path = f"{table_path}/_migration_marker"
    marker = 0

    try:
        marker = int(dbutils.fs.head(mm_path, 10))
    except Exception as e:
        if "java.io.FileNotFoundException" in str(e):
            print("Migration marker not found")
        else:
            raise e

    if marker &amp;lt; 1:
        sql = f"""CREATE TABLE catalog.schema.tablename ... LOCATION {table_path}"""
        spark.sql(sql).count()
        marker = 1
        dbutils.fs.put(mm_path, marker, True)

    if marker &amp;lt; 2:
        sql = f"""ALTER TABLE catalog.schema.tablename ..."""
        spark.sql(sql).count()
        marker = 2
        dbutils.fs.put(mm_path, marker, True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 01:43:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/migration-scripts-for-distribution-embedded-in-library/m-p/37346#M26327</guid>
      <dc:creator>matty_f</dc:creator>
      <dc:date>2023-07-11T01:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Migration scripts for distribution, embedded in library</title>
      <link>https://community.databricks.com/t5/data-engineering/migration-scripts-for-distribution-embedded-in-library/m-p/37652#M26418</link>
      <description>&lt;P&gt;Not much community happening here&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 02:01:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/migration-scripts-for-distribution-embedded-in-library/m-p/37652#M26418</guid>
      <dc:creator>matty_f</dc:creator>
      <dc:date>2023-07-15T02:01:25Z</dc:date>
    </item>
  </channel>
</rss>

