title: truncate and restart identity of a set of tables
body: <p>My application uses <code>Postgresql</code>. <br>
  I would need to remove all rows from a set of tables (<code>table1</code> to <code>table4</code>) and restart the <code>id</code> with one command from a rb file.</p>
  
  <p>In the <a href="https://www.postgresql.org/docs/9.1/static/sql-truncate.html" rel="nofollow noreferrer">Postgresql documentation</a> I found that TRUNCATE with RESTART IDENTITY would do the job as follows:</p>
  
  <pre><code>TRUNCATE table1, table2, table3, table4 RESTART IDENTITY;
  </code></pre>
  
  <p>According to <a href="https://stackoverflow.com/questions/7606386/how-to-restart-id-counting-on-a-table-in-postgresql-after-deleting-some-previous">How to restart id counting on a table in PostgreSQL after deleting some previous data?</a> at Stackoverflow, I can use the following command:</p>
  
  <pre><code>ActiveRecord::Base.connection.execute("TRUNCATE TABLE your_table_name RESTART IDENTITY")
  </code></pre>
  
  <p>So putting together the two documentations, would it be correct to use the following command:</p>
  
  <pre><code>ActiveRecord::Base.connection.execute("TRUNCATE table1, table2, table3, table4 RESTART IDENTITY")
  </code></pre>
  
  <p>considering that in the <a href="http://apidock.com/rails/ActiveRecord/Base/connection" rel="nofollow noreferrer">API dock</a> documentation the <code>connection</code> method is reported as deprecated or moved?.</p>